blob: c4ef0ae36ea568683c184343552da1a27c9a6e00 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#include <stdio.h>
#include <stdlib.h>
void draw(int ops, int x)
{
if ( (ops) % 40 <= x + 2 && (ops) % 40 >= x )
{
printf("#");
} else {
printf(".");
}
if ((ops) % 40 == 0) {
printf("\n");
}
}
int main()
{
char *line = NULL;
size_t len;
int ops = 1;
int x = 1;
int signal = 0;
while (getline(&line, &len, stdin) != -1)
{
draw(ops, x);
if (line[0] == 'a') {
ops++;
draw(ops, x);
int a = atoi(line+5);
x += a;
// printf("%d\n", a);
}
ops++;
}
printf("%d\n", signal);
}
|