fork download
  1. #include <stdlib.h>
  2. #include <iostream>
  3. using namespace std;
  4. void r(char s, char e, int n, char* c,int k){
  5. for (char i=s; i<=e; i++) {
  6. c[k] = i;
  7. if (n>k+1) r(s,e,n,c,k+1);
  8. cout << c << endl;
  9. }
  10. c[k] = '\0';
  11. }
  12. void func(char s, char e, int n){
  13. char* c = (char*)malloc(n+1);
  14. c[n] = '\0';
  15. r(s,e,n,c,0);
  16. free(c);
  17. }
  18. int main(){
  19. func('a', 'c', 3);
  20. return 0;
  21. }
Success #stdin #stdout 0s 3028KB
stdin
Standard input is empty
stdout
aaa
aab
aac
aa
aba
abb
abc
ab
aca
acb
acc
ac
a
baa
bab
bac
ba
bba
bbb
bbc
bb
bca
bcb
bcc
bc
b
caa
cab
cac
ca
cba
cbb
cbc
cb
cca
ccb
ccc
cc
c