Linux
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
void check(string num)
{
cout << "checking " << num << endl;
string cmd = "time -p ./main < in" + num + ".txt > output";
cout << cmd << endl;
system(cmd.c_str());
string diff = "diff -B out" + num + ".txt output";
system(diff.c_str());
cout << endl;
}
int main()
{
if (system("g++ -std=c++14 -c ./test.cc -o ./main.o")) {
cout << "Compile Error" << endl;
return 0;
}
system("g++ -o ./main ./main.o");
//system("./main");
for (int i = 1; ; i++) {
char ch = i + '0';
string num;
num += ch;
string name = "in" + num + ".txt";
if (!access(name.c_str(), 0)) {
check(num);
} else {
return 0;
}
}
}
Windows
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
void check(string num)
{
cout << "checking " << num << endl;
string cmd = "main < in" + num + ".txt > output";
cout << cmd << endl;
system(cmd.c_str());
string diff = "fc out" + num + ".txt output";
system(diff.c_str());
cout << endl;
}
int main()
{
if (system("g++ -std=c++14 -c ./main.cc -o ./main.o")) {
cout << "Compile Error" << endl;
return 0;
}
system("g++ -o main main.o");
//system("./main");
for (int i = 1; ; i++) {
char ch = i + '0';
string num;
num += ch;
string name = "in" + num + ".txt";
if (!access(name.c_str(), 0)) {
check(num);
} else {
return 0;
}
}
}