-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
39 lines (33 loc) · 933 Bytes
/
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
#include <iostream>
#include "plot.h"
bool checkError(int argc, int i) {
if(i+1 >= argc) {
std::cout << "Args error" << std::endl;
return true;
}
return false;
}
int main(int argc, char *argv[]) {
double size = 10;
double step = 1;
bool loop = false;
for(int i = 0; i < argc; i++) {
std::string arg = argv[i];
if(arg == "-size") {
if(checkError(argc, i)) return 1;
size = std::stod(argv[++i]);
} else if(arg == "-step") {
if(checkError(argc, i)) return 1;
step = std::stod(argv[++i]);
} else if(arg == "-l" || arg == "-loop") {
loop = true;
}
}
std::string input;
std::cout << "y = ";
std::getline(std::cin, input);
Graph graph(size, step);
if(!loop) graph.Plot(input);
else graph.Loop(input);
return 0;
}