/home/toolbox/public_html/solutions/1/101/b.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 256
16
17 #define MOVE 1
18 #define PILE 2
19 #define ONTO 3
20 #define OVER 4
21
22 /*
23 * Author: Isaac Traxler
24 * Date: 2014-10-30
25 * Purpose: fun
26 * Problem: 101 - The Blocks Problem
27 */
28
29 /*
30 * This template reads data until a terminating value is reached.
31 */
32
33 int size;
34 char line[MAX_LINE];
35 int cmd;
36 int kind;
37 int a;
38 int b;
39
40
41 void init()
42 {
43 /* FUNCTION init */
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(line, MAX_LINE, stdin);
57 line[strlen(line)-1] = 0;
58 dataReadFlag = 'q' != line[0];
59 return (dataReadFlag);
60 } /* FUNCTION getInput */
61
62 void parseLine()
63 {
64 /* FUNCTION parseLine */
65 if (NULL != strstr(line, "pile"))
66 cmd = MOVE;
67 else
68 cmd = PILE;
69
70 if (NULL != strstr(line, "over"))
71 cmd = ONTO;
72 else
73 cmd = OVER;
74
75 sscanf(line, " %d %d ", &a, &b);
76 } /* FUNCTION parseLine */
77
78 void process()
79 {
80 /* FUNCTION process */
81 sscanf(line, " %d %d ", &a, &b);
82 printf(" [%s] %d %d \n", line, a, b);
83 } /* FUNCTION process */
84
85 int main ()
86 {
87 /* main */
88 int moreToDo;
89
90 init();
91 moreToDo = getInput();
92 while (moreToDo)
93 {
94 /* while */
95 process();
96 moreToDo = getInput();
97 } /* while */
98
99 return EXIT_SUCCESS;
100 } /* main */
101