如何用灰度图像用C语言写g代码?
/*不知道你是什么水平。我是一个新手,不熟悉编程语言。下面是我做的一个小程序,可以在所有C语言编译器上运行(vc++6.0,turbo…………......),还可以进一步完善。这是一个类似蛇的小游戏。好运*//* Snake */# include # include # include inth head = 3,tail = 0;intmain(){inti,j,k = 0;intzuo Biao[2][80];longstartintdirection = 77intgamespeedinttimeoverintchange(charqipan[20][80],intzuobiao[2][80],char direction);左标[0][尾]= 1;左标[1][尾]= 1;左标[0][1]= 1;左标[1][1]= 2;左标[0][2]= 1;左标[1][2]= 3;左标[0][头]= 1;左标[1][头]= 4;/*处理棋盘*/charqipan[20][80];//定义棋盘为(I = 0;我& lt20;i++)for(j = 0;j & lt80;j++)潘琪[I][j]=“”;//初始化棋盘为(I = 0;我& lt80;i++)潘琪[0][I]= ' _ ';for(I = 0;我& lt20;i++)潘琪[I][0]= ' | ';for(I = 0;我& lt20;i++)潘琪[I][79]= ' | ';for(I = 0;我& lt80;i++)潘琪[19][I]= ' _ ';潘琪[1][1]=潘琪[1][2]=潘琪[1][3]= ' * ';//初始化蛇潘琪的位置[1][4]= ' # ';printf("ThisisagameofaSNAKE。\nGOODLUCKTOYOU!\ n ");printf("请输入您的游戏速度。(如300)\ n ");scanf("%d ",& ampgamespeed);而(方向!= ' q '){ system(" cls ");for(I = 0;我& lt20;I++)//打印出棋盘for(j = 0;j & lt80;j++)printf("%c ",潘琪[I][j]);time over = 1;start =时钟();而(!kb hit()& amp;& amp(time over = clock()-start & lt;= gamespeed));if(time over){ getch();direction = getch();} elsedirection =方向;如果(!(方向= = 72 | |方向= = 80 | |方向= = 75 | |方向= = 77)){ return 0;系统(“cls”);printf("GAMEOVER!\ n ");}如果(!change(潘琪,左标,方向)){ direction = ' q系统(“cls”);printf("GAMEOVER!\ n ");} } return0}intchange(charqipan[20][80],intzuobao[2][80],chardirection){intx,y;if(direction = = 72)x =左标[0][头]-1;y =左标[1][头];if(direction = = 80)x =左标[0][头]+1;y =左标[1][头];if(direction = = 75)x =左标[0][头];y =左标[0][头]-1;if(direction = = 77)x =左标[0][头];y =左标[1][头]+1;if(x = = 0 | | x = = 18 | | y = = 78 | | y = = 0)返回0;如果(潘琪[x][y]!= ' ')return 0;潘琪[左标[0][尾]][左标[1][尾]]= ' ';tail =(tail+1)% 80;潘琪[左标[0][头]][左标[1][头]]= ' * ';head =(head+1)% 80;左标[0][头]= x;左标[1][头]= y;潘琪[左标[0][头]][左标[1][头]]= ' # ';return 1;}