mirror of
https://gitee.com/yyz_o/bk_bishe_pi.git
synced 2025-09-07 23:21:26 +00:00
Compare commits
2 Commits
9ba913646c
...
e5fac173be
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5fac173be | ||
|
|
0b8d29917f |
@@ -45,3 +45,6 @@ void output_arrwall(int size_x, int size_y, int *arr); //打印wall数组
|
||||
void output_arrpath(int size, int *arr); //打印path数组
|
||||
/*---以上为数组打印部分涉及到的函数声明---*/
|
||||
|
||||
/*---以下为目标点输入函数声明---*/
|
||||
void cin_targey(); //输入目标点
|
||||
/*---以上为目标点输入函数声明---*/
|
||||
@@ -1,7 +1,6 @@
|
||||
#include<iostream>
|
||||
#include<string>
|
||||
#include<vector>
|
||||
#include"eyebot++.h"
|
||||
#include"maze_parameter.h"
|
||||
#include"maze_func.h"
|
||||
using namespace std;
|
||||
|
||||
26
bot_code_turn/maze_func_cin.cpp
Normal file
26
bot_code_turn/maze_func_cin.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include<iostream>
|
||||
#include<string>
|
||||
#include<vector>
|
||||
#include"maze_parameter.h"
|
||||
#include"maze_func.h"
|
||||
using namespace std;
|
||||
|
||||
void cin_targey()
|
||||
{
|
||||
int size_x = mark.size();
|
||||
int size_y = mark[0].size();
|
||||
|
||||
int num = 0;
|
||||
do
|
||||
{
|
||||
if (!num)
|
||||
{
|
||||
cout << "您输入的目标点超出迷宫范围,请重新输入" << endl;
|
||||
}
|
||||
cout << "请输入目标点的X,Y坐标值 用空格隔开并回车" << endl;
|
||||
cin >> target_x >> target_y;
|
||||
cout << endl;
|
||||
num++;
|
||||
} while (target_x <= size_x && target_y <= size_y);
|
||||
cout << endl;
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
#include<string>
|
||||
#include<vector>
|
||||
#include<cstddef>
|
||||
#include<cstdlib>
|
||||
#include"eyebot++.h"
|
||||
#include"maze_parameter.h"
|
||||
#include"maze_func.h"
|
||||
@@ -117,6 +118,7 @@ void maze_entry(int x, int y, int dir, int open)
|
||||
else
|
||||
{
|
||||
cout << "error: mark or wall empty" << endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
wall[x][y+1][0] = !open;
|
||||
@@ -141,6 +143,7 @@ void maze_entry(int x, int y, int dir, int open)
|
||||
else
|
||||
{
|
||||
cout << "error: mark or wall empty" << endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
wall[x][y][1] = !open;
|
||||
@@ -165,6 +168,7 @@ void maze_entry(int x, int y, int dir, int open)
|
||||
else
|
||||
{
|
||||
cout << "error: mark or wall empty" << endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
wall[x][y][0] = !open;
|
||||
@@ -181,6 +185,7 @@ void maze_entry(int x, int y, int dir, int open)
|
||||
else
|
||||
{
|
||||
cout << "error: mark or wall empty" << endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
wall[x+1][y][1] = !open;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include<iostream>
|
||||
#include<string>
|
||||
#include<vector>
|
||||
#include"eyebot++.h"
|
||||
#include"maze_parameter.h"
|
||||
#include"maze_func.h"
|
||||
using namespace std;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include<iostream>
|
||||
#include<string>
|
||||
#include"eyebot++.h"
|
||||
#include"maze_func.h"
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include<iostream>
|
||||
#include<string>
|
||||
#include<vector>
|
||||
#include"eyebot++.h"
|
||||
#include<cstdlib>
|
||||
#include"maze_parameter.h"
|
||||
#include"maze_func.h"
|
||||
using namespace std;
|
||||
@@ -36,7 +36,8 @@ void build_path(int i, int j, int len, int *path, int *map, int *copy_wall)
|
||||
}
|
||||
else
|
||||
{
|
||||
LCDPrintf("ERROR");
|
||||
cout << "error" << endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include<iostream>
|
||||
#include<string>
|
||||
#include<vector>
|
||||
#include<cstdlib>
|
||||
#include"eyebot++.h"
|
||||
#include"maze_parameter.h"
|
||||
#include"maze_func.h"
|
||||
@@ -32,10 +33,7 @@ int main()
|
||||
cout << endl;
|
||||
output_arrwall(mazesize_x, mazesize_y, copy_wall); //打印墙壁wall信息
|
||||
|
||||
cout << "请输入目标点的X,Y坐标值 用空格隔开并回车" << endl;
|
||||
cout << endl;
|
||||
cin >> target_x >> target_y;
|
||||
cout << endl;
|
||||
cin_targey(); //输入目标点,带超界检测
|
||||
|
||||
int map[mazesize_x * mazesize_y] = {}; //创建最短路径求解地图并初始化为0
|
||||
array_negative_one(mazesize_x * mazesize_y, map); //将map数组初始化为-1
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include<iostream>
|
||||
#include<string>
|
||||
#include<vector>
|
||||
#include"eyebot++.h"
|
||||
#include"maze_parameter.h"
|
||||
// #include"maze_func.h"
|
||||
using namespace std;
|
||||
|
||||
Reference in New Issue
Block a user