-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
52 lines (35 loc) · 907 Bytes
/
Copy pathmain.cpp
File metadata and controls
52 lines (35 loc) · 907 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
46
47
48
49
50
51
#include "main.h"
#include <iostream>
#include <string.h>
using std::endl;
using std::cout;
solution_t solution_vec[1024];
void show_solved_item();
int main(int argc, char *argv[]) {
if (argc < 2) {
std::cout << "./main question No.\n";
return 0;
}
if (memcmp(argv[1], "--list", 6) == 0) {
show_solved_item();
return 0;
}
int index = atoi(argv[1]);
if (!(1 <= index && index <= 1023)) {
std::cout << "please input the correct qeustion No.\n";
return 0;
}
argv[1] = argv[0];
if (solution_vec[index])
return solution_vec[index](argc-1, argv+1);
else
std::cout << "this problem isnot solved, maybe you can do it!\n";
return 0;
}
void show_solved_item() {
cout << "sovled item: " << endl;
for (int i = 0; i < sizeof(solution_vec)/sizeof(solution_vec[0]); i++) {
if (solution_vec[i])
cout << "\t" << i << endl;
}
}