-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest3.cpp
More file actions
53 lines (40 loc) · 933 Bytes
/
test3.cpp
File metadata and controls
53 lines (40 loc) · 933 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
52
53
#include <iostream>
using namespace std;
int n = 5;
int dx[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
int dy[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
int map[5][5] = { {1,2,0,0,5}, {0,0,8,9,10}, {11,12,13,0,0}, {16,17,0,19,0}, {21,22,23,24,25}};
bool check_path(int x, int y) {
if(x >= n || x < 0 || y >= n || y < 0) {
return false;
}
return true;
}
int move(int x, int y, int len, int direction) {
int move_len = n % ((len - 1) * 2);
int nx = x;
int ny = y;
int d = direction;
for(int i=0; i<move_len; i++) {
nx = x + dx[d];
ny = y + dy[d];
if(!check_path(nx, ny)) {
//
}
}
}
void print_map() {
for(int i=0; i<5; i++) {
for(int j=0; j<5; j++) {
cout << map[i][j] << " ";
}
cout << "\n";
}
cout << "\n";
}
int main() {
map[2][3] = -1;
print_map();
move(1000);
print_map();
}