求助,谁有一个有趣的C语言小程序,而且必须要有源代码!!

学习“推箱子”的c语言编码;

# include & ltstdio.h & gt

# include & ltconio.h & gt

# include & ltstdlib.h & gt

# include & ltwindows.h & gt

int m = 0;?//m代表哪一级。

结构映射{ short a[9][11];};

结构映射map[5]={ 0,0,0,0,0,0,0,0,0,0,0,0,?//***5级,每级9行。

?0,1,1,1,1,1,1,1,0,0,0,

?0,1,0,0,0,0,0,1,1,1,0,

?1,1,4,1,1,1,0,0,0,1,0, ?//0空地,1墙

1,5,0,0,4,0,0,4,0,1,0, ?//4是盒子,5是人。

?1,0,3,3,1,0,4,0,1,1,0, ?//3是目的地

?1,1,3,3,1,0,0,0,1,0,0, ?//7表示盒子在目的地(4+3)

?0,1,1,1,1,1,1,1,1,0,0, ?//8是目的地的人(5+3)

?0,0,0,0,0,0,0,0,0,0,0,

?0,0,0,0,0,0,0,0,0,0,0,

?0,0,1,1,1,1,0,0,0,0,0,

?0,0,1,5,0,1,1,1,0,0,0,

?0,0,1,0,4,0,0,1,0,0,0,

0,1,1,1,0,1,0,1,1,0,0,

?0,1,3,1,0,1,0,0,1,0,0,

?0,1,3,4,0,0,1,0,1,0,0,

?0,1,3,0,0,0,4,0,1,0,0,

?0,1,1,1,1,1,1,1,1,0,0,

?0,0,0,0,0,0,0,0,0,0,0,

?0,0,0,1,1,1,1,1,1,1,0,

?0,0,1,1,0,0,1,0,5,1,0,

?0,0,1,0,0,0,1,0,0,1,0,

0,0,1,4,0,4,0,4,0,1,0,

?0,0,1,0,4,1,1,0,0,1,0,

?1,1,1,0,4,0,1,0,1,1,0,

?1,3,3,3,3,3,0,0,1,0,0,

?1,1,1,1,1,1,1,1,1,0,0,

?0,1,1,1,1,1,1,1,1,1,0,

?0,1,0,0,1,1,0,0,0,1,0,

?0,1,0,0,0,4,0,0,0,1,0,

?0,1,4,0,1,1,1,0,4,1,0,

0,1,0,1,3,3,3,1,0,1,0,

?1,1,0,1,3,3,3,1,0,1,1,

?1,0,4,0,0,4,0,0,4,0,1,

?1,0,0,0,0,0,1,0,5,0,1,

?1,1,1,1,1,1,1,1,1,1,1,

?0,0,0,0,0,0,0,0,0,0,0,

?0,0,0,1,1,1,1,1,1,0,0,

?0,1,1,1,0,0,0,0,1,0,0,

?1,1,3,0,4,1,1,0,1,1,0,

1,3,3,4,0,4,0,0,5,1,0,

?1,3,3,0,4,0,4,0,1,1,0,

?1,1,1,1,1,1,0,0,1,0,0,

?0,0,0,0,0,1,1,1,1,0,0,

?0,0,0,0,0,0,0,0,0,0,0 };

void DrMap()?//画一张地图

{控制台_光标_信息光标_信息={1,0 };//隐藏光标设置

SetConsoleCursorInfo(GetStdHandle(STD _ OUTPUT _ HANDLE),& ampcursor _ info);

Printf("\n\n \t\t\b推框");

printf(" \ n \ t ");

for(int I = 0;我& lt9;i++)

{ for(int j = 0;j & lt11;j++)

{开关(映射[m].a[i][j])

{案例0:?printf("?);打破;

案例1:?printf("■");打破;

?案例三:?printf("◎";打破;

案例四:?printf("□");打破;

案例五:?printf("♂";打破;?//5是人

案例七:?printf("□");打破;?//4+3盒子在目的地。

案例八:?printf("♂";打破;//目的地5+3人

}

}

printf(" \ n \ t ");

}

}

void gtxy(int x,int y)?//控制光标位置的函数

{ COORD coord

坐标。X = x

坐标。Y = y

SetConsoleCursorPosition(GetStdHandle(STD _ OUTPUT _ HANDLE),coord);

}

void start()?//开始游戏

{ int r,c;?//r,c用来记录人的下标。

for(int I = 0;我& lt9;i++)

{ for(int j = 0;j & lt11;j++)

?{if (map[m].a[I][j]= = 5 | |地图[m]。a[I][j]= = 8){ r = I;?c = j;}} //i j人的下标

}

char键;?

key = getch();

开关(钥匙)

{大小写‘W’:

案例“w”:

案例72:

if(映射[m].a[r - 1][c] == 0||地图[m]。a [r - 1][c] == 3)

{ gtxy(2*c+8,r-1+3);printf("♂";?// gtxy(2*c+8,r-1+3)是输出到指定位置的字符。

?if(映射[m].a[r ][c] == 5){gtxy(2*c+8,r+3);printf("?);}

if(映射[m].a[r ][c] == 8){gtxy(2*c+8,r+3);printf("◎";}

地图[m]。a[r-1][c]+= 5;?地图[m]。a[r][c]-= 5;}

不然呢?if(映射[m].a [r - 1][c] == 4 ||地图[m]。a [r - 1][c] == 7)

{ if (map[m].a [r - 2][c] == 0 ||映射[m]。a[r-2][c]= 3)

{ gtxy(2*c+8,r-2+3);printf("□");gtxy(2*c+8,r-1+3);printf("♂";

if(映射[m].a[r ][c] == 5){gtxy(2*c+8,r+3);printf("?);}

if(映射[m].a[r ][c] == 8){gtxy(2*c+8,r+3);printf("◎";}

地图[m]。a[r-2][c]+= 4;?地图[m]。a[r-1][c]+= 1;

?地图[m]。a[r][c]-= 5;}

}破;

案例:

案例:

案例80:

if(映射[m].a [r + 1][c] == 0 ||地图[m]。a [r + 1][c] == 3)

?{ gtxy(2*c+8,r+1+3);printf("♂";

?if(映射[m].a[r ][c] == 5){gtxy(2*c+8,r+3);printf("?);}

?if(映射[m].a[r ][c] == 8){gtxy(2*c+8,r+3);printf("◎";}

?地图[m]。a[r+1][c]+= 5;?地图[m]。a[r][c]-= 5;}

?else if (map[m].a [r + 1][c] == 4 ||地图[m]。a [r+ 1][c] == 7)

?{ if (map[m].a [r + 2][c] == 0 ||映射[m]。a [r + 2][c] == 3)

{ gtxy(2*c+8,r+2+3);printf("□");gtxy(2*c+8,r+1+3);printf("♂";

?if(映射[m].a[r ][c] == 5){gtxy(2*c+8,r+3);printf("?);}

?if(映射[m].a[r ][c] == 8){gtxy(2*c+8,r+3);printf("◎";}

?地图[m]。a[r+2][c]+= 4;地图[m]。a[r+1][c]+= 1;

地图[m]。a[r][c]-= 5;}

?}破;

案例“A”:

案例“a”:

案例75:

if(映射[m].a [r ][c - 1] == 0 ||地图[m]。a [r ][c - 1] == 3)

?{ gtxy(2*(c-1)+8,r+3);printf("♂";

?if(映射[m].a[r ][c] == 5){gtxy(2*c+8,r+3);printf("?);}

?if(映射[m].a[r ][c] == 8){gtxy(2*c+8,r+3);printf("◎";}

?地图[m]。a[r][c-1]+= 5;地图[m]。a[r][c]-= 5;}

?else if (map[m].a [r][c - 1] == 4 ||地图[m]。a [r][c - 1] == 7)

?{if (map[m].a [r ][c - 2] == 0 ||映射[m]。a [r ][c - 2] == 3)

{ gtxy(2*(c-2)+8,r+3);printf("□");gtxy(2*(c-1)+8,r+3);printf("♂";

?if(映射[m].a[r ][c] == 5){gtxy(2*c+8,r+3);printf("?);}

?if(映射[m].a[r ][c] == 8){gtxy(2*c+8,r+3);printf("◎";}

?地图[m]。a[r][c-2]+= 4;地图[m]。a[r][c-1]+= 1;

?地图[m]。a[r][c]-= 5;}

?}破;

案例“D”:

案例“d”:

案例77:

if(映射[m].a [r][c + 1] == 0 ||地图[m]。a [r][c + 1] == 3)

?{ gtxy(2*(c+1)+8,r+3);printf("♂";

?if(映射[m].a[r ][c] == 5){gtxy(2*c+8,r+3);printf("?);}

?if(映射[m].a[r ][c] == 8) {gtxy(2*c+8,r+3);printf("◎";}

?地图[m]。a[r][c+1]+= 5;?地图[m]。a[r][c]-= 5;}

?else if (map[m].a [r][c + 1] == 4 ||地图[m]。a [r][c + 1] == 7)

?{ if (map[m].a [r][c + 2] == 0 ||映射[m]。a [r][c + 2] == 3)

{ gtxy(2*(c+2)+8,r+3);printf("□");gtxy(2*(c+1)+8,r+3);printf("♂";

?if(映射[m].a[r ][c] == 5){gtxy(2*c+8,r+3);printf("?);}

if(映射[m].a[r ][c] == 8){gtxy(2*c+8,r+3);printf("◎";}

地图[m]。a[r][c+2]+= 4;地图[m]。a[r][c+1]+= 1;

地图[m]。a[r][c]-= 5;}

?}破;

}

}

int ifwan()?//是否完成(1为0和否)

{ if(m==0){if(map[m].a[5][2]= = 7 & amp;& amp地图[m]。a[5][3]= = 7 & amp;& amp

?地图[m]。a[6][2]= = 7 & amp;& amp地图[m]。a[6][3]==7)返回1;}

if(m==1){if(map[m].a[5][2]= = 7 & amp;& amp地图[m]。a[6][2]= = 7 & amp;& amp

?地图[m]。a[7][2]==7)返回1;}

if(m==2){if(map[m].a[7][1]= = 7 & amp;& amp地图[m]。a[7][2]= = 7 & amp;& amp地图[m]。a[7][3]= = 7 & amp;& amp

地图[m]。a[7][4]= = 7 & amp;& amp地图[m]。a[7][5]==7)返回1;}

if(m==3){if(map[m].a[4][4]= = 7 & amp;& amp地图[m]。a[4][5]= = 7 & amp;& amp地图[m]。a[4][6]= = 7 & amp;& amp

地图[m]。a[5][4]= = 7 & amp;& amp地图[m]。a[5][5]= = 7 & amp;& amp地图[m]。a[5][6]==7)返回1;}

if(m==4){if(map[m].a[3][2]= = 7 & amp;& amp地图[m]。a[4][1]= = 7 & amp;& amp地图[m]。a[4][2]= = 7 & amp;& amp

地图[m]。a[5][1]= = 7 & amp;& amp地图[m]。a[5][2]==7)返回1;}

返回0;

}

int main()?//主函数

{ while (1)

{ system(" cls ");

?dr map();

?while (1)

?{ start();

if(if wan()){ printf(" \ 007 ");打破;}//完成后响铃。

?}

?m+= 1;

}

?返回0;

}