-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain (conflicted).cpp
81 lines (67 loc) · 1.41 KB
/
main (conflicted).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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "Main_Header.h"
char symbol(Cell* a,Cell* b);
string FullPath(stack<Cell*> path)
{
string str = " ";
Cell* a = path.top();
path.pop();
Cell* b;
while (!path.empty())
{
b = path.top();
path.pop();
str+= symbol(a,b);
a = b;
}
return str;
}
char symbol(Cell* a,Cell* b)
{
if(a->GetCol() < b->GetCol())
return 'R';
else if(a->GetCol() > b->GetCol())
return 'L';
else if(a->GetRow() < b->GetRow())
return 'D';
else if(a->GetRow() > b->GetRow())
return 'U';
}
int main(int argc, char* argv[])
{
// Will store the path to the file to open
char path[_MAX_PATH];
// If the path is supplied as a command line argument, read it
if(argc == 2)
{
strcpy_s(path, _MAX_PATH, argv[1]);
}
else
{
std::cout << "Enter path to labyrinth file: ";
std::cin.getline(path, _MAX_PATH);
}
// Create a board and try to load the contents of the file
Board board;
std::cout << "Trying to load labyrinth from \"" << path << "\"...";
if(board.LoadFromFile(path))
{
std::cout << "done\n\n";
// If loading was successful, print the board
board.Print();
if (board.GetRowsCount() == 0)
{
std::cout << "The board is empty.\n";
return 0;
}
stack<Cell*> st = aStar(board,board.GetStart(),board.GetEnd());
cout << endl;
if (st.empty())
{
cout<< " There is no path\n";
}
board.Print();
//string str = FullPath(st);
//cout<<str;
}
return 0;
}