-
Notifications
You must be signed in to change notification settings - Fork 0
/
accuracy.cpp
36 lines (33 loc) · 846 Bytes
/
accuracy.cpp
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
#include "hmm.h"
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main(int argc, char *argv[])
{
FILE *result_file = open_or_die(argv[1], "r");
FILE *answer_file = open_or_die(argv[2], "r");
char result[MAX_LINE];
char answer[MAX_LINE];
int total = 0;
int bingo = 0;
// int ten = 0;
for (int i = 0; fscanf(result_file, "%s", result) > 0 & fscanf(answer_file, "%s", answer) > 0; i++)
{
// printf("%s ", result);
// printf("%s ", answer);
if (strcmp(result, answer) == 0)
{
bingo++;
// printf("bingo\n");
}
else
{
// printf("\n");
}
total++;
}
double ratio = (double)bingo / (double)total;
printf("%d / %d = %f\n", bingo, total, ratio);
}