PCLP2/test1/02.cpp
Fándly Gergő f41fb09a60 chore: test1
2020-05-10 15:22:32 +03:00

45 lines
751 B
C++

#include <iostream>
#include <vector>
#include <string>
using namespace std;
void generatePermutations(vector<char>* chset, int length, string cur = "") {
if(cur.size() >= length) {
cout<<cur<<"\n";
return;
}
for(vector<char>::iterator it = chset->begin(); it < chset->end(); it++) {
cur.push_back(*it);
generatePermutations(chset, length, cur);
cur.pop_back();
}
}
int main() {
ios::sync_with_stdio(false);
int n;
cout<<"Char set size: ";
cin>>n;
vector<char> chset;
for(int i=0; i<n; i++){
cout<<"Character nr."<<i+1<<": ";
char c;
cin>>c;
chset.push_back(c);
}
int k;
cout<<"Generated word length: ";
cin>>k;
cout<<"Generated combinations:\n";
generatePermutations(&chset, k);
cout.flush();
return 0;
}