-
Notifications
You must be signed in to change notification settings - Fork 0
/
doubleComparatorChecker.cpp
57 lines (49 loc) · 1.16 KB
/
doubleComparatorChecker.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
// input.txt → avtor bergan input
// author.txt → avtor bergan output
// code.txt → userning kodi
// user.txt → user bergan output
#include <bits/stdc++.h>
#define ac 0xAC
#define wa 0xAD
#define pe 0xAE
#define tl 0xAF
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ifstream input("input.txt");
ifstream output("author.txt");
ifstream user_output("user.txt");
ifstream code("code.txt");
void ret(int x) {
input.close();
output.close();
user_output.close();
code.close();
exit(x);
}
int main()
{
// necha xona aniqlikda ekanligini belgilash uchun
// bunda 5 xonagacha aniqlikka tekshiriladi
double max_error = 1e-5;
// unutmang bu faqat bitta son chiqadigan holat uchun
// output bir nechta son bo'lganda kodni o'zingizga moslashtiring
try {
double ans, user_ans;
output >> ans;
user_output >> user_ans;
string s;
if (user_output >> s) {
ret(pe);
}
if (abs(ans - user_ans) <= max_error) {
ret(ac);
}
else {
ret(wa);
}
}
catch (const std::exception& e) {
ret(pe);
}
}