/home/toolbox/public_html/solutions/4/488/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
10 #define TRUE (1 == 1)
11 #define FALSE (1 != 1)
12
13 #define DEBUG if (FALSE)
14
15 /* fprintf(stderr, "functionName: message", varslist); */
16
17 /*
18 * Author: Isaac Traxler
19 * Date: 2014-10-29
20 * Purpose: fun
21 * Problem: 488 - Triangular Wave
22 */
23
24 /*
25 * This template reads data a specified number of times.
26 */
27
28 int amp;
29 int freq;
30
31 int numberOfTimes;
32
33 void init()
34 {
35 /* FUNCTION init */
36 scanf("%d ", &numberOfTimes);
37 } /* FUNCTION init */
38
39 void dump()
40 {
41 /* FUNCTION dump */
42 } /* FUNCTION dump */
43
44 void getInput()
45 {
46 /* FUNCTION getInput */
47 scanf(" %d %d ", &, &freq);
48 } /* FUNCTION getInput */
49
50 void process()
51 {
52 /* FUNCTION process */
53 int a;
54 int f;
55 int i;
56
57 for (f=1; f<=freq; f++)
58 {
59 /* do each wave */
60 for (a=1; a<=amp; a++)
61 {
62 /* do leading edge */
63 for (i=0; i<a; i++)
64 {
65 printf("%d", a);
66 }
67 printf("\n");
68 } /* do leading edge */
69 for (a=amp-1; 0<a ; a--)
70 {
71 /* do trailing edge */
72 for (i=0; i<a; i++)
73 {
74 printf("%d", a);
75 }
76 printf("\n");
77 } /* do trailing edge */
78 if (f != freq)
79 {
80 printf("\n");
81 }
82 } /* do each wave */
83 } /* FUNCTION process */
84
85 int main ()
86 {
87 /* main */
88 int i;
89
90 init();
91 for (i=0; i<numberOfTimes; i++)
92 {
93 /* while */
94 getInput();
95 if (0 != i)
96 {
97 printf("\n");
98 }
99 process();
100 } /* while */
101
102 return EXIT_SUCCESS;
103 } /* main */
104
105