Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void permute(char * input, char * next);
- void remove(char * destination, char * source, int position);
- void permute(char * input) {
- char buffer[] = { 0 };
- permute(input,buffer);
- }
- void permute(char * input, char * next) {
- if (!input[0]) printf("%s\n",next);
- for (int i = 0; *(input+i); ++i) {
- char buff[128];
- char _buff[128];
- remove(buff,input,i);
- int len = strlen(next);
- memcpy(_buff,input+i,1);
- memcpy(_buff+1,next,len+1);
- permute(buff, _buff);
- }
- }
- void remove(char * output, char * input, int pos) {
- int length = strlen(input), posi = 0;
- for (int i = 0; i <= length; ++i)
- if (pos != i) output[posi++] = *(input+i);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement