#include <stdio.h> #define SWAP(a,b) {int temp = a; a = b; b = temp;} #define N 10 void perm(char str[],int count,int t) { if (t==count-1){ for (int i=0;i<count;++i) printf("%c",str[i]); printf("\n"); } else{ for (int j=t;j<count;++j){ SWAP(str[t],str[j]); t++; perm(str,count,t); t--; SWAP(str[t],str[j]); } } } int main() { int t=0; char str[N]=""; int count=0; printf("Enter a number:\n"); gets(str); while(str[count]){ count++; } printf("res:\n"); perm(str,count,t); return 0; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)