/home/toolbox/public_html/solutions/116/11687/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 #include <ctype.h>
10
11 #define TRUE (1 == 1)
12 #define FALSE (1 != 1)
13
14 #define DEBUG if (FALSE)
15
16
17 /*
18 * Author: Isaac Traxler
19 * Date: 2023-11-07
20 * Purpose: fun
21 * Problem: 11687
22 */
23
24 /*
25 * This template reads lines of data at a time until end of file.
26 */
27
28 #define MAX_LINE 1000005
29
30 char line[MAX_LINE+1];
31
32 void init()
33 {
34 /* FUNCTION init */
35 } /* FUNCTION init */
36
37 void dump()
38 {
39 /* FUNCTION dump */
40 } /* FUNCTION dump */
41
42 int getInput()
43 {
44 /* FUNCTION getInput */
45 int dataReadFlag;
46
47 fgets(line, MAX_LINE, stdin);
48 if (feof(stdin))
49 dataReadFlag = FALSE;
50 else
51 {
52 /* something to read */
53 dataReadFlag = 'E' != line[0];
54 line[strlen(line)-1] = 0;
55 } /* something to read */
56 return (dataReadFlag);
57 } /* FUNCTION getInput */
58
59 void process()
60 {
61 /* FUNCTION process */
62 int cnt = 1;
63 int tmp;
64
65 tmp = strlen(line);
66 if ((1 == tmp) && ('0' == line[0]))
67 printf("2\n");
68 else
69 {
70 /* calculate */
71 while ((1 != tmp) || ('1' != line[0]))
72 {
73 /* while */
74 DEBUG printf("(cnt %d) (tmp %d) (line:%s)\n", cnt, tmp, line);
75 cnt++;
76 sprintf(line, "%d", tmp);
77 tmp = strlen(line);
78 } /* while */
79 printf("%d\n", cnt);
80 } /* calculate */
81 } /* FUNCTION process */
82
83 int main()
84 {
85 /* main */
86 int moreToDo;
87
88 init();
89 moreToDo = getInput();
90 while (moreToDo)
91 {
92 /* while */
93 process();
94 moreToDo = getInput();
95 } /* while */
96
97 return EXIT_SUCCESS;
98 } /* main */
99