blob: 018e00e5d2bce77a57b5ee7dad1fc5d143cfda3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#include <stdio.h>
#include <string.h>
void swap(char* a, char* b) {
char t = *a;
*a = *b;
*b = t;
}
void anagrams(char* str, int l, int r) {
if(l == r)
printf("%s\n", str);
else
for(int i = l; i < r; i++) {
swap(&str[l], &str[i]);
anagrams(str, l+1, r);
//swap(&str[l], &str[i]);
}
}
int main() {
char str[30];
scanf("%s", str);
anagrams(str, 0, strlen(str));
return 0;
}
|