-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommandLine.cpp
More file actions
45 lines (39 loc) · 840 Bytes
/
commandLine.cpp
File metadata and controls
45 lines (39 loc) · 840 Bytes
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
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char*argv[]) {
if (argc != 2) {
cerr << "Invalid nummber of arguments" << endl;
return 1;
}
string choice = argv[1];
string best = "best";
string worst = "worst";
if (choice.compare(best) == 0) {
cout << "BEST" << endl;
} else if (choice.compare(worst) == 0) {
cout << "WORST" << endl;
} else {
cout << "You didn't pick an algorithm" << endl;
return 1;
}
int n;
bool validInput = false;
while (!validInput || n!=5) {
cout << "Enter 1-5" << endl;
cin >> n;
if (cin.fail()) {
cin.clear();
cin.ignore(256, '\n');
validInput = false;
}
if (n>=1 && n<=5) {
validInput = true;
cout << "Do option(" << n << ")" << endl;
}
else {
cout << "Input invalid" << endl;
validInput = false;
}
}
}