以下是贪吃蛇源代码:#include#include#include#include坦数#include#define N 21void gotoxy(int x,int y)//位置函数{COORD pos;pos.X=2*x;pos.Y=y;SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);}void color(int a)//颜色函数{SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);}void init(int apple[2])//初始化函数(初始化围墙、显示信息、苹果){int i,j;//初始化围墙int wall[N+2][N+2]={{0}};for(i=1;i<=N;i++){for(j=1;j<=N;j++)wall[i][j]=1;}color(11);for(i=0;i0;i--){snake[i][0]=snake[i-1][0];snake[i][1]=snake[i-1][1];gotoxy(snake[i][0],snake[i][1]);color(14);cout<<"★"<