Commit 451b4b5a authored by Zhiwei PEI's avatar Zhiwei PEI

Add CHANGELOG

parent 4c195b0a
#include<stdio.h>
#include<conio.h>
#include<windows.h>
int map[16][17]={
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,4,1,0,1,0,1,4,0,0,0,0,3,0,0,4,1},
{1,2,1,4,0,0,0,1,0,1,1,0,1,1,0,0,1},
{1,3,1,1,1,0,3,0,0,0,0,0,0,0,1,0,1},
{1,0,1,0,0,0,1,1,0,3,1,0,1,0,0,0,1},
{1,0,1,0,1,3,0,0,1,4,1,0,0,1,3,1,1},
{1,0,0,1,0,0,1,1,1,1,1,0,0,0,4,4,1},
{1,0,0,3,0,0,0,0,0,4,1,1,0,0,1,0,1},
{1,0,0,1,1,1,0,0,1,0,1,0,3,1,0,0,1},
{1,0,3,0,0,4,1,0,0,1,0,0,0,1,1,0,1},
{1,1,1,1,0,0,1,0,0,0,0,0,1,0,0,0,1},
{1,0,0,0,1,0,1,0,1,3,1,1,0,0,1,1,1},
{1,0,3,0,1,1,1,0,0,0,0,0,0,0,0,4,1},
{1,1,0,0,0,0,1,0,1,0,0,1,0,0,1,1,1},
{1,4,0,0,1,0,0,0,0,1,0,0,3,0,0,4,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
};
int drawmain();
int tuidong();
int winshu();
int main()
{
while(1)
{
system("cls");
drawmain();
tuidong();
}
printf("shuchu \n");
return 0;
}
int drawmain()
{
int i,j;
winshu();
for(i=0;i<16;i++)
{
for(j=0;j<17;j++)
{
switch(map[i][j])
{
case 0:
printf(" ");
break;
case 1:
printf("¡ö");
break;
case 2:
printf("¡â");
break;
case 3:
printf("¡î");
break;
case 4:
printf("¡ò");
break;
case 6:
printf("¡á");
break;
case 7:
printf("¡ï") ;
break;
}
}
printf("\n");
}
}
int tuidong()
{
int count,caw=0;
int i,j,tui;
for(i=0;i<16;i++){
for (j=0;j<17;j++)
{
if(map[i][j]==2||map[i][j]==6)
{
count=i;
caw=j;
}
}
}
tui=getch();
switch(tui)
{
case 'W':
case 72:
if(map[count-1][caw]==0||map[count-1][caw]==4)
{
map[count][caw]-=2;
map[count-1][caw]+=2;
}
else if(map[count-1][caw]==3||map[count-1][caw]==7)
{
if(map[count-2][caw]==0||map[count-2][caw]==4)
{
map[count][caw]-=2;
map[count-1][caw]-=1;
map[count-2][caw]+=3;
}
}
break;
case 'S':
case 80:
if(map[count+1][caw]==0||map[count+1][caw]==4)
{
map[count][caw]-=2;
map[count+1][caw]+=2;
}
else if(map[count+2][caw]==0||map[count+2][caw]==4)
{
if(map[count+1][caw]==3||map[count+1][caw]==7)
{
map[count][caw]-=2;
map[count+1][caw]-=1;
map[count+2][caw]+=3;
}
}
break;
case 'A':
case 75:
if(map[count][caw-1]==0||map[count][caw-1]==4)
{
map[count][caw]-=2;
map[count][caw-1]+=2;
}
else if(map[count][caw-2]==0||map[count][caw-2]==4)
{
if(map[count][caw-1]==3||map[count][caw-1]==7)
{
map[count][caw]-=2;
map[count][caw-1]-=1;
map[count][caw-2]+=3;
}
}
break;
case 'D':
case 77:
if(map[count][caw+1]==0||map[count][caw+1]==4)
{
map[count][caw]-=2;
map[count][caw+1]+=2;
}
else if(map[count][caw+2]==0||map[count][caw+2]==4)
{
if(map[count][caw+1]==3||map[count][caw+1]==7)
{
map[count][caw]-=2;
map[count][caw+1]-=1;
map[count][caw+2]+=3;
}
}
break;
}
}
int winshu()
{
int k = 0;
int j,i;
for(i=0;i<16;i++)
{
for (j=0;j<17;j++)
{
if(map[i][j]==3)
k++;
}
}
if(k==0)
printf("congratulation!!!\nyou won!!!\n");
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment