#include <bits/stdc++.h>
#include <windows.h>
using namespace std;
int n = 10;
char a[25][25];
bool vis[25][25];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
void print(int x, int y){
system("cls");
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
if(i == x && j == y)cout << 'A';
else cout << a[i][j];
}cout << "\n";
}
}
void dfs(int x, int y){
if(x == n && y == n){
print(x, y);
Sleep(1000);
cout << "YES\n";
Sleep(10000000);
return;
}
for(int i = 0; i < 4; i++){
print(x, y);
Sleep(600);
int wx = x + dx[i], wy = y + dy[i];
if(wx > n || wy > n || wx < 1 || wy < 1 || a[wx][wy] == '#' || vis[wx][wy]){
continue;
}
vis[wx][wy] = 1;
dfs(wx, wy);
vis[wx][wy] = 0;
}
cout << "NO\n";
}
int main(){
for(int i = 1; i <= n; i++){
cin >> a[i] + 1;
}
dfs(1, 1);
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main(){
freopen(".out", "w", stdout);
srand((int)time(0));
for(int i = 1; i <= 10; i++){
for(int j = 1; j <= 10; j++){
int x = rand() % 7;
if(x == 1 || x == 3 || x == 5 || x == 6 || x == 0)cout << '.';
else cout << '#';
}cout << "\n";
}
return 0;
}
各位大佬觉得怎么样?