Algorithm to print all combination of letters of the given string in lexicographical order
问题 I tried to create the code to generate all possible combination of the given string in the lexicographical order: The code that I wrote is: void get(char *n) { int l=strlen(n); sort(n,n+l); int k=0,m,i,j,z; while(k<l) { m=k; for(i=k;i<l;i++) { for(j=k;j<=i;j++) cout<<n[j]; cout<<"\n"; } for(z=m+2;z<l;z++) cout<<n[m]<<n[z]<<"\n"; k++; } } int main() { char n[100]; cin>>n; get(n); return 0; } Suppose the string is : abcde My code is not generating combinations like: abd abe The output I am