fork(6) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void Gen(string haslo,int size,const string alfabet)
  5. {
  6. if (haslo.length()>=size) cout<<haslo<<endl;
  7. else for(int i=0;i<alfabet.length();++i) Gen(haslo+alfabet[i],size,alfabet);
  8. }
  9.  
  10. int main()
  11. {
  12. string alfabet="ab";
  13. Gen("",2,alfabet);
  14. return 0;
  15. }
  16.  
  17.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
aa
ab
ba
bb