2021-12-02 11:12:54 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
FILE *fp = fopen("input.txt", "r");
|
2021-12-02 17:21:50 +01:00
|
|
|
char buf[16] = {0};
|
2021-12-02 11:12:54 +01:00
|
|
|
unsigned n, h = 0, v = 0;
|
|
|
|
|
|
|
|
while (fgets(buf, 16, fp) != NULL) {
|
2021-12-02 17:21:50 +01:00
|
|
|
sscanf(buf, "%*s %u", &n);
|
2021-12-02 11:12:54 +01:00
|
|
|
|
|
|
|
switch (buf[0]) {
|
|
|
|
case 'd':
|
|
|
|
v += n;
|
|
|
|
break;
|
|
|
|
case 'u':
|
|
|
|
v -= n;
|
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
h += n;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Answer: %u\n", h * v);
|
|
|
|
}
|