-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecker.c
47 lines (41 loc) · 1.01 KB
/
checker.c
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
41
42
43
44
45
46
47
#include <stdio.h>
#include <ctype.h>
#define LENGTH 40
int main(void)
{
char ans, correct[LENGTH], input[LENGTH];
int i, count, score;
for (i = 0; i < LENGTH; i++)
{
ans = ' ';
while (!(ans >= 'A' && ans <= 'D'))
{
printf("%2i : \n", i + 1);
scanf(" %c", &ans);
ans = toupper(ans);
}
input[i] = ans;
}
i = 0;
ans = ' ';
while ((ans = getchar()) != EOF && i < LENGTH)
if (ans >= 'A' && ans <= 'D')
{
correct[i] = ans;
i++;
}
score = LENGTH;
for (i = 0, count = 0; count < LENGTH / 2; i+= 2, count++)
if (input[count] != correct[i])
{
score--;
printf("%i ", count + 1);
}
for (i = 1, count = 20; count < LENGTH; i+= 2, count++)
if (input[count] != correct[i])
{
score--;
printf("%i ", count + 1);
}
printf("%i\n", score);
}