天天达
    以下是使用Dev-C++编写的贪吃蛇游戏的源代码示例: ### C语言版本 ```c #include<stdio.h> #include<stdlib.h> #include<Windows.h> #include<time.h> #include<malloc.h> #include<assert.h> #define rowMap 20 #define colMap 40 int succesScore=20; enum Direction { D, A, S, W, }dir; enum State { eatSelf, crashWall, nomal, success, exitWindow, again, }sta; struct snake { size_t x; size_t y; struct snake*next; }; void startGame(); void runGame(); void endGame(); struct snake*snakeHead = NULL; struct snake*food=NULL; int sleepTime=500; int score=0; int everyScore=1; int countTime=0; const char Food = '#'; const char Snake='*'; void pos(int x,int y) { COORD pos; pos.X = x; pos.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); } // 省略了其他函数和代码... ``` ### C++版本 ```cpp #include<iostream> #include<windows.h> #include<conio.h> #include<deque> #include<ctime> #include<stdexcept> using namespace std; struct Snake{//蛇类结构体 char image; short x, y;//坐标 }; class snakeGame{ public: snakeGam