Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
miniProject
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Zhiwei PEI
miniProject
Commits
451b4b5a
Commit
451b4b5a
authored
Nov 01, 2020
by
Zhiwei PEI
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add CHANGELOG
parent
4c195b0a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
185 additions
and
0 deletions
+185
-0
le code
le code
+185
-0
No files found.
le code
0 → 100644
View file @
451b4b5a
#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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment