/home/toolbox/public_html/solutions/127/12770/c.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <fcntl.h>
6 #include <stdint.h>
7 #include <math.h>
8 #include <stdlib.h>
9
10 #define TRUE (1 == 1)
11 #define FALSE (1 != 1)
12
13 #define DEBUG if (FALSE)
14
15 /*
16 * Author: Isaac Traxler
17 * Date: 2015-09-29
18 * Purpose: fun
19 * Problem: 12770
20 */
21
22 /*
23 * This template reads data until a terminating value is reached.
24 */
25
26 #define MAX_SIZE 505
27 #define START ('a' + 0)
28 #define STOP (START + 26)
29
30 char buff[MAX_SIZE];
31 int let[255];
32
33 void init()
34 {
35 /* FUNCTION init */
36 int i;
37
38 DEBUG printf("start = %c(%d) stop = %c(%d)\n", START, START, STOP-1, STOP-1);
39 for (i=START; i<STOP; i++)
40 {
41 /* for */
42 let[i] = 0;
43 } /* for */
44 } /* FUNCTION init */
45
46 void dump()
47 {
48 /* FUNCTION dump */
49 } /* FUNCTION dump */
50
51 int getInput()
52 {
53 /* FUNCTION getInput */
54 int dataReadFlag;
55
56 fgets(buff, MAX_SIZE, stdin);
57 dataReadFlag = ('#' != buff[0]);
58 DEBUG printf("[%s] %d\n", buff, strlen(buff));
59 return (dataReadFlag);
60 } /* FUNCTION getInput */
61
62 void process()
63 {
64 /* FUNCTION process */
65 int i;
66 char prv;
67 int tmp;
68
69 tmp = strlen(buff) - 1;
70 DEBUG printf("lenght = %d\n", tmp);
71 for (i=0; i<tmp; i++)
72 {
73 /* for each character */
74 let[buff[i]]++;
75 } /* for each character */
76 prv = ' ';
77 for (i=START; i<STOP; i++)
78 {
79 /* for each letter */
80 if (1 == (let[i] % 2))
81 {
82 /* found an odd count */
83 if (' ' != prv)
84 {
85 printf("%c", prv);
86 }
87 prv = i;
88 } /* found an odd count */
89 } /* for each letter */
90 printf("\n");
91 } /* FUNCTION process */
92
93 int main()
94 {
95 /* main */
96 int moreToDo;
97
98 moreToDo = getInput();
99 while (moreToDo)
100 {
101 /* while */
102 init();
103 process();
104 moreToDo = getInput();
105 } /* while */
106
107 return EXIT_SUCCESS;
108 } /* main */
109