-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathValidation.cpp
executable file
·73 lines (65 loc) · 1.15 KB
/
Validation.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
using namespace std;
const int N = 100010;
const double eps = 1e-5;
double a[N], b[N], c[N];
int main(int argc, char* argv[]){
bool t = true;
double x;
ifstream f1("ans");
if (!f1.is_open()) {
cout<<"Error: ans file not found"<<endl;
return 0;
}
int n = 0;
while (f1 >> x) {
a[n++] = x;
}
ifstream f2("cpu");
if (!f2.is_open()) {
cout<<"Error: cpu file not found"<<endl;
return 0;
}
int n1 = 0;
while (f2 >> x) {
b[n1++] = x;
}
if (n1 != n) {
cout<<"CPU file invalid!"<<endl;
t = false;
} else {
for (int i = 0; i < n; i++)
if (fabs(a[i] - b[i]) > eps) {
cout<<"CPU file invalid!"<<endl;
t = false;
break;
}
}
ifstream f3("mpi");
if (!f3.is_open()) {
cout<<"Error: mpi file not found"<<endl;
return 0;
}
int n2 = 0;
while (f3 >> x) {
c[n2++] = x;
}
if (n2 != n) {
cout<<"MPI file invalid!"<<endl;
t = false;
} else {
for (int i = 0; i < n; i++)
if (fabs(a[i] - c[i]) > eps) {
cout<<"MPI file invalid!"<<endl;
t = false;
break;
}
}
if (t)
cout<<"Valid!"<<endl;
return 0;
}