提交 e888716d 编写于 作者: 道标 · 年's avatar 道标 · 年 🙂

上传新文件

上级 257e20d7
#include <iostream>
#include <conio.h>
using namespace std;
void ten()
{
cout << "wsad = 上下左右, @ 为终点 ,O 为你的位置" << endl;
char a[10][10] =
{
{'#','#','#','#','#','#','#','#','#','#'},
{'#',' ',' ','#','#',' ','#','#',' ','@'},
{'#',' ','#',' ',' ',' ',' ','#',' ','#'},
{'#',' ',' ',' ','#','#',' ','#',' ','#'},
{'#','O',' ','#','#',' ',' ','#',' ','#'},
{'#',' ','#',' ',' ','#',' ',' ',' ','#'},
{'#',' ','#',' ',' ','#',' ','#',' ','#'},
{'#',' ',' ','#','#',' ',' ',' ',' ','#'},
{'#','#',' ',' ',' ',' ','#','#',' ','#'},
{'#','#','#','#','#','#','#','#','#','#'},
};
for(int i = 0; i < 10; i++)
{
for(int j = 0; j < 10; j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
char ch;
int x = 4, y = 1;
int q = 1, p = 9;
while(ch = getch())
{
system("cls");
cout << "wsad = 上下左右, @ 为终点 ,O 为你的位置" << endl;
if(ch == 'w' && a[x - 1][y] != '#')
{
a[x][y] = ' ';
x--;
a[x][y] = 'O';
}
else if(ch == 's' && a[x + 1][y] != '#')
{
a[x][y] = ' ';
x++;
a[x][y] = 'O';
}
else if(ch == 'a' && a[x][y - 1] != '#')
{
a[x][y] = ' ';
y--;
a[x][y] = 'O';
}
else if(ch == 'd' && a[x][y + 1] != '#')
{
a[x][y] = ' ';
y++;
a[x][y] = 'O';
}
for(int i = 0; i < 10; i++)
{
for(int j = 0; j < 10; j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
if(x == q && y == p)
{
cout << "win";
break;
}
}
}
void eleven()
{
cout << "wsad = 上下左右, @ 为终点 ,O 为你的位置" << endl;
char a[11][11] =
{
{'#','#','#','#','#','#','#','#','#','#','#'},
{'#','O','#','#','#',' ','#','#','#','#','#'},
{'#',' ','#',' ','#','#','#','#',' ',' ',' '},
{'#',' ','#',' ','#',' ','#','#',' ','#',' '},
{'#',' ','#',' ',' ',' ','#','#',' ','#',' '},
{'#',' ',' ',' ','#',' ','#','#',' ','#',' '},
{'#',' ','#','#','#',' ','#',' ',' ','#','@'},
{'#',' ','#','#','#',' ','#','#',' ','#',' '},
{'#',' ',' ',' ','#',' ','#','#',' ','#','#'},
{'#','#','#',' ',' ',' ',' ',' ',' ','#','#'},
{'#','#','#','#','#','#','#','#','#','#','#'},
};
for(int i = 0; i < 11; i++)
{
for(int j = 0; j < 11; j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
char ch;
int x = 1, y = 1;
int q = 6, p = 10;
while(ch = getch())
{
system("cls");
cout << "wsad = 上下左右, @ 为终点 ,O 为你的位置" << endl;
if(ch == 'w' && a[x - 1][y] != '#')
{
a[x][y] = ' ';
x--;
a[x][y] = 'O';
}
else if(ch == 's' && a[x + 1][y] != '#')
{
a[x][y] = ' ';
x++;
a[x][y] = 'O';
}
else if(ch == 'a' && a[x][y - 1] != '#')
{
a[x][y] = ' ';
y--;
a[x][y] = 'O';
}
else if(ch == 'd' && a[x][y + 1] != '#')
{
a[x][y] = ' ';
y++;
a[x][y] = 'O';
}
for(int i = 0; i < 11; i++)
{
for(int j = 0; j < 11; j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
if(x == q && y == p)
{
cout << "win";
break;
}
}
}
void twelve()
{
cout << "wsad = 上下左右, @ 为终点 ,O 为你的位置" << endl;
char a[12][12] =
{
{'#','#','#','#','#','#','#','#','#','#','#','#'},
{'#',' ',' ',' ',' ','#','#','#','#','#','#','#'},
{'#','O','#','#',' ','#','#',' ','#','#',' ',' '},
{'#',' ',' ','#',' ',' ',' ',' ','#',' ',' ','#'},
{'#','#',' ','#','#','#','#',' ','#',' ','#',' '},
{'#',' ',' ','#','#',' ','#',' ',' ',' ','#','@'},
{'#','#',' ',' ','#',' ','#','#','#','#','#',' '},
{'#','#','#',' ','#','#','#','#',' ',' ',' ',' '},
{'#',' ','#',' ',' ',' ','#','#',' ','#',' ',' '},
{'#',' ','#','#','#',' ',' ',' ',' ','#','#','#'},
{'#','#','#','#','#','#','#','#','#','#','#','#'},
};
for(int i = 0; i < 12; i++)
{
for(int j = 0; j < 12; j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
char ch;
int x = 2, y = 1;
int q = 5, p = 11;
while(ch = getch())
{
system("cls");
cout << "wsad = 上下左右, @ 为终点 ,O 为你的位置" << endl;
if(ch == 'w' && a[x - 1][y] != '#')
{
a[x][y] = ' ';
x--;
a[x][y] = 'O';
}
else if(ch == 's' && a[x + 1][y] != '#')
{
a[x][y] = ' ';
x++;
a[x][y] = 'O';
}
else if(ch == 'a' && a[x][y - 1] != '#')
{
a[x][y] = ' ';
y--;
a[x][y] = 'O';
}
else if(ch == 'd' && a[x][y + 1] != '#')
{
a[x][y] = ' ';
y++;
a[x][y] = 'O';
}
for(int i = 0; i < 12; i++)
{
for(int j = 0; j < 12; j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
if(x == q && y == p)
{
cout << "win";
break;
}
}
}
void thirteen()
{
cout << "wsad = 上下左右, @ 为终点 ,O 为你的位置" << endl;
char a[13][13] =
{
{'#','#','#','#','#','#','#','#','#','#','#','#','#'},
{'#',' ','#','#','#','#','#','#','#','#','#','#','#'},
{'#','O','#','#','#','#','#','#','#','#','#','#','#'},
{'#',' ','#','#','#','#','#','#','#','#','#','#','#'},
{'#',' ','#','#',' ',' ',' ','#','#','#','#','#','#'},
{'#',' ',' ',' ',' ','#',' ','#','#','#','#','#','#'},
{'#',' ','#','#',' ','#',' ','#','#','#','#','#','#'},
{'#',' ','#','#','#',' ',' ','#','#','#','#','#','#'},
{'#',' ','#','#','#',' ','#','#','#','#','#','#','#'},
{'#',' ',' ',' ',' ',' ','#','#','#','#','#','#','#'},
{'#',' ','#','#','#','#','#','#','#','#','#','#','#'},
{'#',' ',' ',' ',' ',' ','#','#','#','#','#','#','#'},
{'#','#','#','#','#','#','#','#','#','#','#','#','#'},
};
for(int i = 0; i < 12; i++)
{
for(int j = 0; j < 12; j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
char ch;
int x = 2, y = 1;
int q = 5, p = 11;
while(ch = getch())
{
system("cls");
cout << "wsad = 上下左右, @ 为终点 ,O 为你的位置" << endl;
if(ch == 'w' && a[x - 1][y] != '#')
{
a[x][y] = ' ';
x--;
a[x][y] = 'O';
}
else if(ch == 's' && a[x + 1][y] != '#')
{
a[x][y] = ' ';
x++;
a[x][y] = 'O';
}
else if(ch == 'a' && a[x][y - 1] != '#')
{
a[x][y] = ' ';
y--;
a[x][y] = 'O';
}
else if(ch == 'd' && a[x][y + 1] != '#')
{
a[x][y] = ' ';
y++;
a[x][y] = 'O';
}
for(int i = 0; i < 12; i++)
{
for(int j = 0; j < 12; j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
if(x == q && y == p)
{
cout << "win";
break;
}
}
}
int main()
{
int n;
cout << "请输入你想要的级别 1 ~ 5" << endl;
cin >> n;
if(n == 1)
{
ten();
}
else if(n == 2)
{
eleven();
}
else if(n == 3)
{
twelve();
}
else if(n == 4)
{
thirteen();
}
else if(n == 5)
{
forteen();
}
return 0;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册