自己学了三个月写了一个小东西来大老帮看看
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
#define N 10
//定意全局数组
int max[N][N]={
1,1,1,1,1,1,1,1,1,1,
1,0,0,0,0,0,0,0,0,1,
1,0,1,0,3,0,0,0,0,1,
1,0,1,1,0,0,1,1,4,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,2,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,0,0,0,0,0,0,0,1,
1,1,1,1,1,1,1,1,1,1};
//画地图 人♀2 空地 0 箱子 ☆ 3 墙 ■1 目的地 ※ 4 箱子到达目的地 ★ 人站在目的地 5
void printMap(int map[][16]); //游戏
int yx(); //游戏
void C(); //爱心表头
int m(); //闪瞎你的狗眼
int ai(); //推箱子内用
int mai(); //推箱子
int dt(); //画地图
int zhou();//走起来
int xxm();//打包推广箱子
int main()
{
system("color 9f"); //改***r />
int a;
char z[]=" 欢迎来到猛哥的学习世界,非常感谢你能成为我的试验用户";
char x[]=" 《关机》 1";
char x1[]=" 《重新启动计算机》 2";
char x2[]=" 《打开计算器》 3";
char x3[]=" 《新建计事本》 4";
char x4[]=" 《玩个猛哥作的小游戏》 5";
char x5[]=" 《闪瞎你的狗眼不信打开看看》 6";
char x6[]=" 《推箱子游戏》 7";
C();
printf("%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n",z,x,x1,x2,x3,x4,x5,x6);
C();
printf("请输入你需要的服务:如输入 1 选择关机:\n");
do{
scanf("%d",&a);
switch(a)
{
case 1: printf("马上为您关机:");system("shutdown -p"); break;
case 2: printf("马上为您重启:");system("shutdown -r -t 1");break;
case 3: system("calc");break;
case 4: system("notepad");break;
case 5: yx();break;
case 6: m();break;
case 7: system("cls");xxm();break;
default:printf("无效的选择:");
}
}while(a!=0);
system("date");
return 0;
}
void C()
{
int i=0;
while(i<40)
{
printf("%c ",3);
i++;
}
printf("\n");
return ;
}
void printMap(int map[][16])
{
int i=0,j=0;
for(i=0;i<14;i++)
{
for(j=0;j<16;j++)
{
switch(map[i][j])
{
case 0:printf("◎");
break;
case 1:printf("■");
break;
case 2:printf("★");
break;
}
if(j==15)
printf("\n");
}
}
}
int yx() //废物的推箱子 学习用
{
int i,j;
char key;
int map[14][16]=
{
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
};
i=9 ,j=8;
while(1)
{
system("cls");
printMap(map);
key=getch();
switch(key)
{
case 72:
{
map[i-1][j]=2;
map[i][j]=0;
i--;
break;
case 75: //左箭头
map[i][j-1]=2;
map[i][j]=0;
j--;
break;
case 77: //右箭头
map[i][j+1]=2;
map[i][j]=0;
j++;
break;
case 80: //下箭头
map[i+1][j]=2;
map[i][j]=0;
i++;
break;
default:
break;
}
}
}
}
int m()//无限变***r /> {
int a=10;
int i;
for(i=0;i<9999;i++)
{
Sleep(a);
system("color 10");
Sleep(a);
system("color 20");
Sleep(a);
system("color 30");
Sleep(a);
system("color 40");
Sleep(a);
system("color 50");
Sleep(a);
system("color 60");
Sleep(a);
system("color 70");
Sleep(a);
system("color 80");
Sleep(a);
system("color 90");
Sleep(a);
system("color a0");
Sleep(a);
system("color b0");
Sleep(a);
system("color c0");
Sleep(a);
system("color d0");
Sleep(a);
system("color e0");
Sleep(a);
}
return 0;
}
//推箱子游戏
int mai()
{
ai();//打印头
printf("\n\n");
printf("\t\t\t 第一关\n");
int mat[10][10]={
{1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,1,0,0,0,0,1},
{1,0,0,0,1,0,0,0,0,1},
{1,0,0,3,1,0,0,0,0,1},
{1,0,0,1,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,1},
{1,0,0,0,2,0,0,0,0,1},
{1,0,0,0,4,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,1},
{1,1,1,1,1,1,1,1,1,1}};
int i,j;
for(i=0;i<10;i++)
{
printf("\t\t\t ");
for(j=0;j<10;j++)
{
Sleep(20);
switch(mat[i][j])
{
case 0:printf("□");break;
case 1:printf("■");break;
case 2:printf("★");break;
case 3:printf("☆");break;
case 4:printf("♀");break;
}
}printf("\n");
}
printf("\n\n");
ai();
return 0;
}
int ai()
{
int i;
for(i=0;i<40;i++)
{
Sleep(20);
printf("■");
}
}
int dt()
{
int i,j;
for(i=0;i<N;i++)
{
for(j=0;j<N;j++)
{
switch(max[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;
case 5:break;
}
}
printf("\n");
}
}
//动走来
int zhou()
{
int i,j,x,y; //找到人的座标
char o;
for(i=0;i<N;i++)
{
for(j=0;j<N;j++)
{
if(max[i][j]==2||max[i][j]==6)
{
break;
}
}
if(max[i][j]==2||max[i][j]==6)
{
break;
}
}
o=getch();
switch(getch())
{
case 'w': //上
case 'W':
case 72:
if(max[i-1][j]==0||max[i-1][j]==4)
{
max[i-1][j]+=2;
max[i][j]-=2;
break;
}
case 's': //下
case 'S':
case 80:
if(max[i+1][j]==0||max[i+1][j]==4)
{
max[i+1][j]+=2;
max[i][j]-=2;
break;
}
case 'a': //左
case 'A':
case 75:
if(max[i][j-1]==0||max[i+1][j-1]==4)
{
max[i][j-1]+=2;
max[i][j]-=2;
break;
}
case 'd': //右
case 'D':
case 77:
if(max[i][j+1]==0||max[i][j+1]==4)
{
max[i][j+1]+=2;
max[i][j]-=2;
break;
}
}
}
int xxm() //实现推箱子
{
while(1){
dt();
zhou();
system("cls");
}
return 0;
}
#来新手村#
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
#define N 10
//定意全局数组
int max[N][N]={
1,1,1,1,1,1,1,1,1,1,
1,0,0,0,0,0,0,0,0,1,
1,0,1,0,3,0,0,0,0,1,
1,0,1,1,0,0,1,1,4,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,2,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,0,0,0,0,0,0,0,1,
1,1,1,1,1,1,1,1,1,1};
//画地图 人♀2 空地 0 箱子 ☆ 3 墙 ■1 目的地 ※ 4 箱子到达目的地 ★ 人站在目的地 5
void printMap(int map[][16]); //游戏
int yx(); //游戏
void C(); //爱心表头
int m(); //闪瞎你的狗眼
int ai(); //推箱子内用
int mai(); //推箱子
int dt(); //画地图
int zhou();//走起来
int xxm();//打包推广箱子
int main()
{
system("color 9f"); //改***r />
int a;
char z[]=" 欢迎来到猛哥的学习世界,非常感谢你能成为我的试验用户";
char x[]=" 《关机》 1";
char x1[]=" 《重新启动计算机》 2";
char x2[]=" 《打开计算器》 3";
char x3[]=" 《新建计事本》 4";
char x4[]=" 《玩个猛哥作的小游戏》 5";
char x5[]=" 《闪瞎你的狗眼不信打开看看》 6";
char x6[]=" 《推箱子游戏》 7";
C();
printf("%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n",z,x,x1,x2,x3,x4,x5,x6);
C();
printf("请输入你需要的服务:如输入 1 选择关机:\n");
do{
scanf("%d",&a);
switch(a)
{
case 1: printf("马上为您关机:");system("shutdown -p"); break;
case 2: printf("马上为您重启:");system("shutdown -r -t 1");break;
case 3: system("calc");break;
case 4: system("notepad");break;
case 5: yx();break;
case 6: m();break;
case 7: system("cls");xxm();break;
default:printf("无效的选择:");
}
}while(a!=0);
system("date");
return 0;
}
void C()
{
int i=0;
while(i<40)
{
printf("%c ",3);
i++;
}
printf("\n");
return ;
}
void printMap(int map[][16])
{
int i=0,j=0;
for(i=0;i<14;i++)
{
for(j=0;j<16;j++)
{
switch(map[i][j])
{
case 0:printf("◎");
break;
case 1:printf("■");
break;
case 2:printf("★");
break;
}
if(j==15)
printf("\n");
}
}
}
int yx() //废物的推箱子 学习用
{
int i,j;
char key;
int map[14][16]=
{
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
};
i=9 ,j=8;
while(1)
{
system("cls");
printMap(map);
key=getch();
switch(key)
{
case 72:
{
map[i-1][j]=2;
map[i][j]=0;
i--;
break;
case 75: //左箭头
map[i][j-1]=2;
map[i][j]=0;
j--;
break;
case 77: //右箭头
map[i][j+1]=2;
map[i][j]=0;
j++;
break;
case 80: //下箭头
map[i+1][j]=2;
map[i][j]=0;
i++;
break;
default:
break;
}
}
}
}
int m()//无限变***r /> {
int a=10;
int i;
for(i=0;i<9999;i++)
{
Sleep(a);
system("color 10");
Sleep(a);
system("color 20");
Sleep(a);
system("color 30");
Sleep(a);
system("color 40");
Sleep(a);
system("color 50");
Sleep(a);
system("color 60");
Sleep(a);
system("color 70");
Sleep(a);
system("color 80");
Sleep(a);
system("color 90");
Sleep(a);
system("color a0");
Sleep(a);
system("color b0");
Sleep(a);
system("color c0");
Sleep(a);
system("color d0");
Sleep(a);
system("color e0");
Sleep(a);
}
return 0;
}
//推箱子游戏
int mai()
{
ai();//打印头
printf("\n\n");
printf("\t\t\t 第一关\n");
int mat[10][10]={
{1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,1,0,0,0,0,1},
{1,0,0,0,1,0,0,0,0,1},
{1,0,0,3,1,0,0,0,0,1},
{1,0,0,1,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,1},
{1,0,0,0,2,0,0,0,0,1},
{1,0,0,0,4,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,1},
{1,1,1,1,1,1,1,1,1,1}};
int i,j;
for(i=0;i<10;i++)
{
printf("\t\t\t ");
for(j=0;j<10;j++)
{
Sleep(20);
switch(mat[i][j])
{
case 0:printf("□");break;
case 1:printf("■");break;
case 2:printf("★");break;
case 3:printf("☆");break;
case 4:printf("♀");break;
}
}printf("\n");
}
printf("\n\n");
ai();
return 0;
}
int ai()
{
int i;
for(i=0;i<40;i++)
{
Sleep(20);
printf("■");
}
}
int dt()
{
int i,j;
for(i=0;i<N;i++)
{
for(j=0;j<N;j++)
{
switch(max[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;
case 5:break;
}
}
printf("\n");
}
}
//动走来
int zhou()
{
int i,j,x,y; //找到人的座标
char o;
for(i=0;i<N;i++)
{
for(j=0;j<N;j++)
{
if(max[i][j]==2||max[i][j]==6)
{
break;
}
}
if(max[i][j]==2||max[i][j]==6)
{
break;
}
}
o=getch();
switch(getch())
{
case 'w': //上
case 'W':
case 72:
if(max[i-1][j]==0||max[i-1][j]==4)
{
max[i-1][j]+=2;
max[i][j]-=2;
break;
}
case 's': //下
case 'S':
case 80:
if(max[i+1][j]==0||max[i+1][j]==4)
{
max[i+1][j]+=2;
max[i][j]-=2;
break;
}
case 'a': //左
case 'A':
case 75:
if(max[i][j-1]==0||max[i+1][j-1]==4)
{
max[i][j-1]+=2;
max[i][j]-=2;
break;
}
case 'd': //右
case 'D':
case 77:
if(max[i][j+1]==0||max[i][j+1]==4)
{
max[i][j+1]+=2;
max[i][j]-=2;
break;
}
}
}
int xxm() //实现推箱子
{
while(1){
dt();
zhou();
system("cls");
}
return 0;
}
#来新手村#