25 lines
515 B
C
25 lines
515 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int main() {
|
|
FILE *file;
|
|
int count = 0;
|
|
int num = 50, add;
|
|
char rot;
|
|
file = fopen("input.txt", "r");
|
|
if (file == NULL) {
|
|
perror("Error opening file");
|
|
return 1;
|
|
}
|
|
|
|
while (fscanf(file, "%c%d\n", &rot, &add) == 2) {
|
|
num += (rot == 'R') ? add : -add;
|
|
num %= 100;
|
|
if (num < 0)
|
|
num += 100;
|
|
count += num ? 0 : 1;
|
|
}
|
|
fclose(file);
|
|
printf("Password: %d\n", count);
|
|
return 0;
|
|
} |