-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
33 lines (29 loc) · 737 Bytes
/
main.cpp
File metadata and controls
33 lines (29 loc) · 737 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
#include <iostream>
#include "maze.h"
using namespace std;
void test(const string &mazeFile) {
Maze myMaze;
cout << "*** Solving " << mazeFile << endl;
if (!myMaze.load(mazeFile)) {
cerr << "Failed to load " << mazeFile << endl;
return;
}
if (myMaze.solve()) {
cout << "Path: " << myMaze.getPath() << endl;
} else {
cout << "Failed to solve: " << mazeFile << endl;
}
cout << myMaze << endl;
}
// accepts multiple maze files from command line
// ./a.out maze0.txt maze1.txt maze2.txt maze3.txt badfile.txt
int main(int argc, char *argv[]) {
if (argc >= 1) {
for (int i = 1; i < argc; ++i) {
string mazeFile = argv[i];
test(mazeFile);
}
}
cout << "Done!" << endl;
return 0;
}