+ 4
can permutation and combination programming made in c++
if there are six blank space and total digit is 9 .how many no can be made and what no.
4 ответов
+ 20
//yes
//btw here is the solution to your question(incomplete question)
👉if numbers can be repeated then
9^6 //no 0 as a digit
8.9^5//0 as a digit
👉if numbers can't be repeated then
9.8.7.6.5.4 //no 0 as a digit
8.8.7.6.5.4 //0 as a digit
edit ::: understand the role of 0
//specify what digits
if u want code , then try making it by your own first
+ 9
C++'s standard library provided some good facilities to deal with statistical stuff. One of which is "std::next_permutation". As its name suggests you would be able to get the permutation of a bunch of elements.
[http://en.cppreference.com/w/cpp/algorithm/next_permutation]
Example:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
// A list of 4 characters for our experiment
vector<char> vChar = {'b', 'b', 'a', 'c'};
// before doing anything we need to sort our list
sort(vChar.begin(), vChar.end());
// Let's get through our process
while (next_permutation(vChar.begin(), vChar.end())) {
for (const auto i : vChar)
cout << i;
cout << endl;
}
}
Live link: [http://cpp.sh/9abtf]
But, there's no "next_combination" thing in STL. The good news is, by tweaking the next_permutation algorithm you can reach your desired result for the last part of your question.
Here is a good discussion about that matter: [https://stackoverflow.com/questions/9430568/generating-combinations-in-c]
+ 4
you know code please answer
+ 4
Yes, u can do that,
See this:
https://code.sololearn.com/c5Qo2bsY7fa5/?ref=app