📄 main.cpp
字号:
#include <iostream>
#include <cstdlib>
#include "AStar.hpp"
using namespace std;
char map[6*6] = { 'o', 'o', 'o', 'o', 'o', 'o',
'o', 's', ' ', ' ', ' ', 'o',
'o', ' ', 'o', ' ', ' ', 'o',
'o', 'o', 'o', ' ', 'o', 'o',
'o', ' ', ' ', ' ', 'd', 'o',
'o', 'o', 'o', 'o', 'o', 'o'};
void printMap(char *m, const int& rows, const int& cols){
for(int i=0; i<rows; ++i){
for(int j=0; j<cols; ++j)
cout<<m[i * cols + j];
cout<<endl;
}
cout<<endl;
}
int main()
{/*
typedef AStar::priorityQueue PQueue;
typedef AStar::ANode Node;
PQueue q;
Node nodes[6];
for(int i=0; i<6; ++i){
nodes[i].f = i + i;
q.push(&nodes[i]);
}
Node temp;
temp.f = 7;
q.push(&temp);
while(!q.empty()){
cout<<q.top()->f<<endl;
q.pop();
}
*/
#ifdef _DEBUG
TRACE_OFF();
MEM_ON();
#endif
printMap(map, 6, 6);
vector<Point> path;
AStar s(map, 6, 6);
if(!s.findPath(path))
cout<<"no path!"<<endl;
for(vector<Point>::iterator itr=path.begin(); itr!=path.end(); ++itr){
map[(*itr).x * 6 + (*itr).y] = '.';
}
for(int i=0; i<6; ++i){
for(int j=0; j<6; ++j)
cout<<map[i * 6 + j];
cout<<endl;
}
cout<<endl;
#ifdef _DEBUG
MEM_OFF();
#endif
system("PAUSE");
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -