全文预览

2048游戏C语言实验报告

上传者:火锅鸡 |  格式:doc  |  页数:19 |  大小:492KB

文档介绍
ar judge;Р?for(;flag==1;)Р?{Р play();Р for(i=0,flag=0;i<=3;i++)Р {Р for(j=0;j<=3;j++)Р if(A[i][j]==0&&(flag==0||flag==1))flag=1;Р else if(A[i][j]==M)flag=2;Р }Р if(flag==0)Р {Р system("color c7");Р printf("\n\t\t\t任务失败!你总共获得%d分!\n",C);Р }Р else if(flag==2)printf("\n\t\t\t恭喜你获得胜利!你总共获得%d分!\n",C);Р if(flag==0||flag==2)Р {Р printf("是否重新开始?(y or n):");Р judge=getch();Р if(judge=='y')Р {Р system("cls");Р C=0;Р for(i=0;i<=3;i++)Р for(j=0;j<=3;j++)Р A[i][j]=0;Р random();Р random();Р all_printf();Р flag=1;Р system("color 70");Р }Р else break;Р }Р elseР {Р?Р random();Р system("cls");Р all_printf();Р printf("\n");Р printf("\t分数为:%6d\t\t",C);Р }Р?}Р}Рvoid play() /* 操作函数*/Р{Р?char direction;Р?direction=getch();Р?switch(direction)Р?{Р case 'w':up();break;Р case 's':down();break;Р case 'a':left();break;

收藏

分享

举报
下载此文档