/home/toolbox/public_html/solutions/115/11541/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 <stdlib.h>
7 #include <math.h>
8 #include <stdint.h>
9 #include <ctype.h>
10
11 #define TRUE (1 == 1)
12 #define FALSE (1 != 1)
13
14 #define DEBUG if (FALSE)
15
16 /* fprintf(stderr, "functionName: message", varslist); */
17
18 /*
19 * Author: Isaac Traxler
20 * Date: 2021-12-7
21 * Purpose: fun
22 * Problem: 11541 - Decoding
23 */
24
25 /*
26 * This template reads data a specified number of times.
27 */
28
29 #define MAX_LINE 201
30
31 int numberOfTimes;
32 char line[MAX_LINE];
33
34 void init()
35 {
36 /* FUNCTION init */
37 scanf("%d ", &numberOfTimes);
38 } /* FUNCTION init */
39
40 void dump()
41 {
42 /* FUNCTION dump */
43 } /* FUNCTION dump */
44
45 void getInput()
46 {
47 /* FUNCTION getInput */
48 scanf(" %s ", line);
49 } /* FUNCTION getInput */
50
51 void process()
52 {
53 /* FUNCTION process */
54 int i;
55 int j;
56 int tmp;
57 char letter;
58 int slen;
59
60 slen = strlen(line);
61 i=1;
62 letter = line[0];
63 while (slen>i)
64 {
65 /* process string */
66 tmp = 0;
67 while (isdigit(line[i]))
68 {
69 /* get number */
70 tmp = (tmp * 10) + (line[i] - '0');
71 i++;
72 } /* get number */
73 if (0 == tmp)
74 {
75 tmp = 1;
76 }
77 for (j=0; tmp>j; j++)
78 {
79 /* for each time to print */
80 printf("%c", letter);
81 } /* for each time to print */
82 letter = line[i];
83 i++;
84 } /* process string */
85 printf("\n");
86 } /* FUNCTION process */
87
88 int main()
89 {
90 /* main */
91 int i;
92
93 init();
94 for (i=1; i<=numberOfTimes; i++)
95 {
96 /* while */
97 getInput();
98 printf("Case %d: ", i);
99 process();
100 } /* while */
101
102 return EXIT_SUCCESS;
103 } /* main */
104
105