-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrader.cpp
More file actions
57 lines (48 loc) · 1.4 KB
/
Copy pathgrader.cpp
File metadata and controls
57 lines (48 loc) · 1.4 KB
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
// Dev: Autoratch
#include <bits/stdc++.h>
using namespace std;
/* Normal Demo
code code.cpp : your solution code
testin demo.in : input of testcase
testout demo.out : output of testcase
yourout demo.sol : your output
sol : correct output
your : your output
*/
string code,testin,testout,yourout;
fstream sol,your;
bool wrong;
void print(string s)
{
char c[s.length()+1];
for(int i = 0;i < s.length();i++) c[i] = s[i];
c[s.length()] = '\0';
system(c);
}
int main()
{
freopen("config.txt","r",stdin);
cin >> code;
cin >> testin;
cin >> testout;
cin >> yourout;
print("g++ "+code); // compile source code using g++
print("./a.out < "+testin+" > "+yourout); // run source code and store output in yourout
sol.open(testout,ios::in); // open testcase output file
your.open(yourout,ios::in); // open your output file
while(true)
{
char a = sol.get(),b = your.get();
while(a=='\n' or a==' ') a = sol.get();
while(b=='\n' or b==' ') b = your.get();
if(a!=b){ wrong = true; break; }
if(sol.eof() or your.eof()) break;
}
sol.close(),your.close();
while(testin.back()!='.') testin.pop_back();
testin.pop_back();
cout << testin << ' ';
if(!wrong) cout << "Correct!";
else cout << "Incorrect!";
cout << '\n';
}