2 /* From 'Programming Pearls' by Jon Bentley */
3
4 /* sign.c -- sign each line of a file for finding anagrams
5 The input line "stop" gives the output line "opst stop"
6 */
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #define WORDMAX 100
12
13 int charcomp(char *x, char *y)
14 { return *x - *y;
15 }
16
17 int main()
18 { char word[WORDMAX], sig[WORDMAX];
19 while (scanf("%s", word) != EOF) {
20 strcpy(sig, word);
21 qsort(sig, strlen(sig), sizeof(char), charcomp);
22 printf("%s %s\n", sig, word);
23 }
24 return 0;
25 }
26