-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
46 lines (44 loc) · 1.42 KB
/
main.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
#include <iostream>
#include <fstream>
#include <random>
#include <chrono>
using namespace std;
int main() {
int os,random;
cout<<"Make sure that your input file is at inputs and output file is at outputs directories"<<endl;
cout<<"mac(0) or windows(1)";
cin >> os;
cout<< "Random(0) or not(1)";
cin>> random;
cout<< "Input file name:(Please add .txt to end)";
string iname;
string oname;
cin >> iname;
if(random==0) {
string outfile="../inputs/"+iname;
ofstream outFile(outfile);
if(os==0) {
srand(time(NULL));
}else {
srand(time(0));
}
int N = rand()% 1001;
int M = rand() % 1001;
int Q = rand() % (N + M + 1);
cout << "Creating random input..." << endl;
outFile << N << " " << M << " " << Q << endl;
for (int i = 0; i < Q; i++) {
outFile << rand() % 3 + 1 << " " << (rand() % 2 == 0 ? "A" : "B") << rand() % 100001 << endl;
}
cout << "Random input created." << endl;
}
cout<< "Output file name:(Please add .txt to end)";
cin >> oname;
if(os==0) {
string total="../Executable/cmpe250-assignment3 ../inputs/" + iname+ " ../outputs/" + oname;
system(total.c_str());
}else{
string total="cmpe250-assignment3.exe ../inputs/" + iname+ " ../outputs/" + oname;
system(("cd .. & cd Executable & " + total).c_str());
}
}