/home/toolbox/public_html/solutions/118/11847/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 * Author: Isaac Traxler
18 * Date: 2021-12-4
19 * Purpose: fun
20 * Problem: 11847 - Cut the Silver Bar
21 */
22
23 /*
24 * This template reads data until a terminating value is reached.
25 */
26
27 int twos[16] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512,
28 1024, 2048, 4096, 8192, 16384, 32768
29 };
30 int number;
31
32 void init()
33 {
34 /* FUNCTION init */
35
36 } /* FUNCTION init */
37
38 void dump()
39 {
40 /* FUNCTION dump */
41 } /* FUNCTION dump */
42
43 int getInput()
44 {
45 /* FUNCTION getInput */
46 int dataReadFlag;
47
48 scanf(" %d ", &number);
49 dataReadFlag = (0 != number);
50 return (dataReadFlag);
51 } /* FUNCTION getInput */
52
53 void process()
54 {
55 /* FUNCTION process */
56 int i;
57
58 i = 0;
59 while (number >= twos[i])
60 {
61 i++;
62 }
63 i--;
64 printf("%d\n", i);
65 } /* FUNCTION process */
66
67 int main()
68 {
69 /* main */
70 int moreToDo;
71
72 init();
73 moreToDo = getInput();
74 while (moreToDo)
75 {
76 /* while */
77 process();
78 moreToDo = getInput();
79 } /* while */
80
81 return EXIT_SUCCESS;
82 } /* main */
83