-
Notifications
You must be signed in to change notification settings - Fork 4
/
check.cpp
43 lines (42 loc) · 1.18 KB
/
check.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
37
38
39
40
41
42
43
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main(int argc , char ** argv)
{
FILE * answer_serial;
FILE * answer_CSR2;
char * x;
char * y;
x = argv[1];
y = argv[2];
int num,num1,cnt=0;
double CSR2,serial;
answer_serial = fopen(x,"rb+");
answer_CSR2 = fopen(y,"rb+");
fscanf(answer_serial,"%d\n",&num);
fscanf(answer_CSR2,"%d\n",&num1);
for(int i=0;i<num1;i++)
{
fscanf(answer_serial,"%lf\n",&serial);
fscanf(answer_CSR2,"%lf\n",&CSR2);
double ans1,ans2;
ans1 = serial-CSR2>0?serial-CSR2:CSR2-serial;
ans2 = CSR2>0?CSR2:-CSR2;
if(ans1>0.01*ans2)
{
printf("serial:%lf CSR2:%lf\n",serial,CSR2);
cnt++;
}
}
if(cnt==0)
{
printf("Answer is Right! PASS\n");
}
else
{
printf("%d\n",cnt);
printf("Answer is Error! NO PASS\n");
}
return 0;
}