#include <stdlib.h>
#include <iostream>
using namespace std;
void r(char s, char e, int n, char* c,int k){
for (char i=s; i<=e; i++) {
c[k] = i;
if (n>k+1) r(s,e,n,c,k+1);
cout << c << endl;
}
c[k] = '\0';
}
void func(char s, char e, int n){
char* c = (char*)malloc(n+1);
c[n] = '\0';
r(s,e,n,c,0);
free(c);
}
int main(){
func('a', 'c', 3);
return 0;
}
I2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8aW9zdHJlYW0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnZvaWQgcihjaGFyIHMsIGNoYXIgZSwgaW50IG4sIGNoYXIqIGMsaW50IGspewogICAgZm9yIChjaGFyIGk9czsgaTw9ZTsgaSsrKSB7CgkJY1trXSA9IGk7CgkJaWYgKG4+aysxKSByKHMsZSxuLGMsaysxKTsKCQljb3V0IDw8IGMgPDwgZW5kbDsKCX0KCWNba10gPSAnXDAnOwp9CnZvaWQgZnVuYyhjaGFyIHMsIGNoYXIgZSwgaW50IG4pewoJY2hhciogYyA9IChjaGFyKiltYWxsb2MobisxKTsKCWNbbl0gPSAnXDAnOwoJcihzLGUsbixjLDApOwoJZnJlZShjKTsKfQppbnQgbWFpbigpewoJZnVuYygnYScsICdjJywgMyk7CglyZXR1cm4gMDsKfQ==