/home/toolbox/public_html/solutions/4/483/a.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 #define MAX_LINE 2570
16
17 /*
18 * Author: Isaac Traxler
19 * Date: 2015-02-04
20 * Purpose: fun
21 * Problem: 483
22 */
23
24 /*
25 * This template reads lines of data at a time until end of file.
26 */
27
28 char line[MAX_LINE];
29
30 void init()
31 {
32 /* FUNCTION init */
33 } /* FUNCTION init */
34
35 void dump()
36 {
37 /* FUNCTION dump */
38 } /* FUNCTION dump */
39
40 int getInput()
41 {
42 /* FUNCTION getInput */
43 int dataReadFlag;
44
45 fgets(line, MAX_LINE, stdin);
46 if (feof(stdin))
47 dataReadFlag = FALSE;
48 else
49 {
50 /* something to read */
51 dataReadFlag = TRUE;
52 line[strlen(line)-1] = ' ';
53 } /* something to read */
54 return (dataReadFlag);
55 } /* FUNCTION getInput */
56
57 void process()
58 {
59 /* FUNCTION process */
60 char *token;
61 char buffer[MAX_LINE];
62 const char delim[7] = " \t\n\v\f\r";
63 int i;
64
65 DEBUG printf("line: [%s]\n", line);
66 token = strtok(line, delim);
67 while (NULL != token)
68 {
69 /* while */
70 sprintf(buffer, "%s", token);
71 for (i=strlen(buffer)-1; -1<i; i--)
72 {
73 printf("%c", buffer[i]);
74 }
75 token = strtok(NULL, delim);
76 if (NULL != token)
77 {
78 printf(" ");
79 }
80 } /* while */
81
82 } /* FUNCTION process */
83
84 int main()
85 {
86 /* main */
87 int moreToDo;
88 int first = TRUE;
89
90 init();
91 moreToDo = getInput();
92 while (moreToDo)
93 {
94 /* while */
95 if (first)
96 {
97 /* first */
98 first = FALSE;
99 } /* first */
100 else
101 {
102 /* other */
103 printf("\n");
104 } /* other */
105 process();
106 moreToDo = getInput();
107 } /* while */
108
109 return EXIT_SUCCESS;
110 } /* main */
111