首页
资源库
留言板
站点统计
Search
1
[Java] @Data 注解 代码变得简洁
205 阅读
2
[Vue] Vue 使用ElementUI组件
162 阅读
3
[Java] 安装JDK8
131 阅读
4
[Java] 发送消息
122 阅读
5
[C语言] 游戏贪吃蛇
108 阅读
Tools
编程
C/C++
Java
mySQL
python
PHP
Vue
嵌入式系统编程
HTML
数据结构
TypeScript
登录
Search
标签搜索
Java
SpringBoot
数据结构
C/C++
mysql
Vue
tools
redis
游戏
TomCat
linux
arm
嵌入式系统
Mqtt
PHP
maven
图床
github
IDEA
jar
星如雨
累计撰写
48
篇文章
累计收到
2
条评论
首页
栏目
Tools
编程
C/C++
Java
mySQL
python
PHP
Vue
嵌入式系统编程
HTML
数据结构
TypeScript
页面
资源库
留言板
站点统计
搜索到
6
篇与
的结果
2022-08-06
[数据结构] 王道数据结构2023 P18_03
问题描述对长度为n的顺序表L,编写一个时间复杂度为O(n),空间复杂度为O(1)的算法,该算法删除线性表中所有值为x的数据元素实现代码bool DeleteSelectX(SeqList &L,ElementType x){ if(L.lenght == 0){ printf("线性表为空\n"); return false; } int i,j; for(i = 0,j = 0;i < L.lenght;i++){ if(L.data[i] != x){ L.data[j] = L.data[i]; j++; } } L.lenght = j; return true; }全部代码#include <stdio.h> #include <stdbool.h> #include <stdlib.h> #define ElementType int #define InitSize 100 int arr[] = {1,2,3,4,1,6,1,8,9,0}; typedef struct { ElementType *data; int MaxLen,lenght; }SeqList; void InitSeqList(SeqList &L){ L.data = (ElementType *)malloc(sizeof(ElementType) * InitSize); L.MaxLen = InitSize; L.lenght = 0; } bool InsertELem(SeqList &L,int i,ElementType data){ if(i < 1 || i > L.lenght + 1){ printf("位置不合法\n"); return false; } if(L.lenght + 1 > L.MaxLen){ printf("线性表已满\n"); return false; } for(int j = L.lenght;j >= i;j--){ L.data[j] = L.data[j - 1]; } L.data[i - 1] = data; L.lenght += 1; return true; } void ShowList(SeqList L){ for(int i = 0;i < L.lenght;i++){ printf("%d ", L.data[i]); } printf("\n"); } bool DeleteSelectX(SeqList &L,ElementType x){ if(L.lenght == 0){ printf("线性表为空\n"); return false; } int i,j; for(i = 0,j = 0;i < L.lenght;i++){ if(L.data[i] != x){ L.data[j] = L.data[i]; j++; } } L.lenght = j; return true; } int main() { SeqList L; InitSeqList(L); for(int i = 0;i < 10;i++){ InsertELem(L,i + 1, arr[i]); } DeleteSelectX(L,1); ShowList(L); return 0; }
2022年08月06日
48 阅读
0 评论
0 点赞
2022-08-05
[数据结构] 王道数据结构2023 P18_02
问题描述设计一个高效算法,将顺序表L的所有元素逆置,要求算法的空间复杂度为O(1)问题分析无代码实现bool ReverseList(SeqList &L){ if(L.lenght == 0){ printf("内容为空\n"); return false; } ElementType temp; for(int i = 0,j = L.lenght - 1;i < j;i++,j--){ temp = L.data[i]; L.data[i] = L.data[j]; L.data[j] = temp; } return true; }算法分析无时间复杂度 O(n)空间复杂度 O(1)完整代码#include <stdio.h> #include <stdbool.h> #include <stdlib.h> #define ElementType int #define InitSize 100 int arr[] = {1,2,3,4,5,6,7,8,9,0}; typedef struct { ElementType *data; int MaxLen,lenght; }SeqList; void InitSeqList(SeqList &L){ L.data = (ElementType *)malloc(sizeof(ElementType) * InitSize); L.MaxLen = InitSize; L.lenght = 0; } bool InsertELem(SeqList &L,int i,ElementType data){ if(i < 1 || i > L.lenght + 1){ printf("位置不合法\n"); return false; } if(L.lenght + 1 > L.MaxLen){ printf("线性表已满\n"); return false; } for(int j = L.lenght;j >= i;j--){ L.data[j] = L.data[j - 1]; } L.data[i - 1] = data; L.lenght += 1; return true; } bool ReverseList(SeqList &L){ if(L.lenght == 0){ printf("内容为空\n"); return false; } ElementType temp; for(int i = 0,j = L.lenght - 1;i < j;i++,j--){ temp = L.data[i]; L.data[i] = L.data[j]; L.data[j] = temp; } return true; } void ShowList(SeqList L){ for(int i = 0;i < L.lenght;i++){ printf("%d ", L.data[i]); } printf("\n"); } int main() { SeqList L; InitSeqList(L); for(int i = 0;i < 10;i++){ InsertELem(L,i + 1, arr[i]); } if(!ReverseList(L)){ printf("线性表反转失败\n"); }else{ printf("线性表反转成功:"); ShowList(L); } return 0; }
2022年08月05日
47 阅读
0 评论
0 点赞
2022-08-05
[数据结构] 王道数据结构2023 P18_01
问题描述从顺序表中删除具有最小值的元素(假设唯一)并由函数返回被删除的值。空出的位置由最后一个元素填补,若顺序表为空,则显示出错信息并退出运行。问题分析无代码实现bool DeleteMin(SeqList &L,ElementType &min){ if(L.lenght == 0){ printf("顺序表为空"); return false; } int flag = 0; for(int i = 0;i < L.lenght;i++){ if(L.data[i] < L.data[flag]){ flag = i; } } min = L.data[flag]; if(flag != L.lenght - 1){ L.data[flag] = L.data[L.lenght - 1]; } L.lenght -= 1; return true; }算法分析无时间复杂度 O(n)空间复杂度 O(1)完整代码#include <stdio.h> #include <stdbool.h> #include <stdlib.h> #define ElementType int #define InitSize 100 int arr[] = {1,2,3,4,5,6,7,8,9,0}; typedef struct { ElementType *data; int MaxLen,lenght; }SeqList; void InitSeqList(SeqList &L){ L.data = (ElementType *)malloc(sizeof(ElementType) * InitSize); L.MaxLen = InitSize; L.lenght = 0; } bool InsertELem(SeqList &L,int i,ElementType data){ if(i < 1 || i > L.lenght + 1){ printf("位置不合法\n"); return false; } if(L.lenght + 1 > L.MaxLen){ printf("线性表已满\n"); return false; } for(int j = L.lenght;j >= i;j--){ L.data[j] = L.data[j - 1]; } L.data[i - 1] = data; L.lenght += 1; return true; } bool DeleteMin(SeqList &L,ElementType &min){ if(L.lenght == 0){ printf("顺序表为空"); return false; } int flag = 0; for(int i = 0;i < L.lenght;i++){ if(L.data[i] < L.data[flag]){ flag = i; } } min = L.data[flag]; if(flag != L.lenght - 1){ L.data[flag] = L.data[L.lenght - 1]; } L.lenght -= 1; return true; } int main() { SeqList L; InitSeqList(L); for(int i = 0;i < 10;i++){ InsertELem(L,i + 1, arr[i]); } int min; if(DeleteMin(L,min)){ printf("删除元素:%d\n", min); for(int i = 0;i < L.lenght;i++){ printf("%d ", L.data[i]); } }else{ printf("删除失败\n"); } return 0; }
2022年08月05日
49 阅读
0 评论
0 点赞
2021-11-28
[C语言] 发送消息
#include <stdio.h> #include <Windows.h> int main(){ int times; char name[100]; //查找窗口的名字 printf("请输入发送对象的姓名:"); scanf("%s", name); printf("请输入发送消息的次数:"); scanf("%d", ×); HWND H = FindWindow(0, name); for(int timesCount = 1;timesCount <= times;timesCount += 1){ Sleep(500); printf("第%d次发送\n", timesCount); SendMessage(H, WM_PASTE, 0, 0); SendMessage(H, WM_KEYDOWN, VK_RETURN, 0); } }正常运行!!!
2021年11月28日
44 阅读
0 评论
0 点赞
2021-11-27
[C语言] 游戏俄罗斯方块
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <windows.h> #define UI_WIDTH 14 //显示界面的宽度 #define UI_HEIGHT 25 //界面的高度 #define WALL 1 #define BLOCK 2 // 四个按键方向 #define U 1 #define D 2 #define L 3 #define R 4 #define MapWidth 15 #define MapHeigth 30 #define TRUE 1 #define FALSE 0 void welcometogame(); void initia(); //初始化的一些工作 void gameShow(); /*游戏显示界面*/ void moveBlock(); /*方块的移动*/ short isCanMoveBlock(short x, short y); //是否能移动方块 void produceBlock(); //产生方块 void toBottom(short x, short y); //方块到底了之后的操作 ,bottom:底 void pause(); //游戏暂停 void creatMap(); void Pos(int x,int y); void welcometogame(); short cur_block_coord_x ,cur_block_coord_y; //当前方块的横坐标及纵坐标// int game_arr[UI_HEIGHT][UI_WIDTH]; //游戏的界面数组 short next_blockarr[4][4]; //用来存放下一个方块的数组 short cur_boxindex,next_boxindex; //记录当前方块的下标和下一个方块的下标 int score = 0; //成绩 int status; // 按键状态 HANDLE hOutput; int flashTime = 100; int flashT = 1; struct _game_arr { short info; //用来存放游戏界面的数组 short var; //用来记录该数组的某个位置是否被占用 ,当方块没有移动了, //该位置才被占用,当移动方块是那个地方被占用就不能移动了 ,用1表示占用,0表示未占用 } game_arr[UI_HEIGHT][UI_WIDTH]; struct _block { short a[4][2]; /*定义方块形状的数组,每个方块共有4个小块组成, 用4行2列来记录每个小方块的相对 坐标, */ short next; //下一个方块的号码 }; struct _block block[19]= { //初始化各个游戏方块, 总共有19总方块形状 { 1, 1, 1, 2, 1, 3, 2, 3, 1}, { 0, 2, 1, 2, 2, 2, 0, 3, 2}, { 0, 1, 1, 1, 1, 2, 1, 3, 3}, { 2, 1, 0, 2, 1, 2, 2, 2, 0}, { 1, 1, 1, 2, 0, 3, 1, 3, 5}, { 0, 1, 0, 2, 1, 2, 2, 2, 6}, { 1, 1, 2, 1, 1, 2, 1, 3, 7}, { 0, 2, 1, 2, 2, 2, 2, 3, 4}, { 1, 1, 0, 2, 1, 2, 2, 2, 9}, { 1, 1, 1, 2, 2, 2, 1, 3,10}, { 0, 2, 1, 2, 2, 2, 1, 3,11}, { 1, 1, 0, 2, 1, 2, 1, 3, 8}, { 1, 1, 1, 2, 2, 2, 2, 3,13}, { 1, 2, 2, 2, 0, 3, 1, 3,12}, { 2, 1, 1, 2, 2, 2, 1, 3,15}, { 0, 2, 1, 2, 1, 3, 2, 3,14}, { 1, 0, 1, 1, 1, 2, 1, 3,17}, { 0, 2, 1, 2, 2, 2, 3, 2,16}, { 1, 1, 2, 1, 1, 2, 2, 2,18} }; void Pos(int x,int y) { //设置光标位置 COORD pos; HANDLE hOutput; pos.X = x; pos.Y = y; hOutput=GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleCursorPosition(hOutput,pos); } int main() { system("mode con cols=40 lines=30"); welcometogame(); initia(); //隐藏缓冲区的光标 CONSOLE_CURSOR_INFO cci; cci.bVisible = 0; cci.dwSize =1; SetConsoleCursorInfo(hOutput, &cci); produceBlock(); moveBlock(); } void initia() { //初始化的一些工作 short i,j; for(i = 0; i < UI_HEIGHT; i++) { for(j = 0; j < UI_WIDTH; j++) { if(i == 0 || i == UI_HEIGHT-1) { game_arr[i][j].info = WALL; //.var=1表示该点被占用 game_arr[i][j].var = 1; continue; } if(j == 0 || j == UI_WIDTH-1) { game_arr[i][j].info = WALL; game_arr[i][j].var = 1; continue; } } } next_boxindex = rand() % 19; //第一次要随机产生两个方块 } /*游戏显示界面*/ void gameShow() { short i,j; for(i = 0; i < UI_HEIGHT; i++) { for(j = 0; j < UI_WIDTH; j++) { if(game_arr[i][j].info == 0) { Pos(j, i); printf(" "); continue; } if(game_arr[i][j].info == WALL) { Pos(j, i); printf("$"); continue; } if(game_arr[i][j].info == BLOCK) { Pos(j, i); printf("#"); } } if(i == 1) printf(" 下一个方块"); if(i >= 2 && i <= 5) { //下一个方块 printf(" "); for(j = 0; j < 4; j++) { if(next_blockarr[i-2][j] == 0) printf(" "); //要减2,因为从i事从2开始的 else printf("#"); } } printf("\\n"); } Pos(20 , 10); printf("得分:%d",score); }/*每一个方块的产生*/ void produceBlock() { //在游戏界面的中间放置方块 short i,j; cur_boxindex = next_boxindex; next_boxindex = rand() % 19; //方块的编号随机产生 cur_block_coord_x = (UI_WIDTH)/2; //从中间落下 cur_block_coord_y = 1; for(i = 0; i < 4; i++) for(j = 0; j < 4; j++) next_blockarr[i][j] = 0; //每次产生新的方块,都要将存放下一个方块的数组清零 for(i = 0; i < 4; i++) { game_arr[cur_block_coord_y+block[cur_boxindex].a[i][1]][cur_block_coord_x+block[cur_boxindex].a[i][0]].info = BLOCK ; next_blockarr[block[next_boxindex].a[i][1]][block[next_boxindex].a[i][0]] = BLOCK; } if( !isCanMoveBlock(cur_block_coord_x,cur_block_coord_y)) { //产生新方块的这个地方被占用了,退出 printf("游戏结束,再接再厉!"); exit(0); } }/*方块的移动*/ void moveBlock() { short i,j,to_bottom = FALSE; //到底 short old_x = cur_block_coord_x,old_y = cur_block_coord_y; //用来记录旧的方块的位置 short old_boxindex = cur_boxindex; //记录方块的下标,按上键时改变方块用 while(1) { old_x = cur_block_coord_x,old_y = cur_block_coord_y; old_boxindex = cur_boxindex; status = 0;// 防止重复 if(GetAsyncKeyState(VK_UP)) { status = U; } else if(GetAsyncKeyState(VK_DOWN)) { status=D; } else if(GetAsyncKeyState(VK_LEFT)) { status=L; } else if(GetAsyncKeyState(VK_RIGHT)) { status=R; } else if(GetAsyncKeyState(VK_SPACE)) { pause(); } switch(status) { case U: cur_boxindex = block[cur_boxindex].next; if(!isCanMoveBlock(cur_block_coord_x, cur_block_coord_y)) cur_boxindex = old_boxindex; //如果不能旋转的话要还原 break; case D: for(i = 0; i < 2; i++) //一次可以下降4个 if(isCanMoveBlock(cur_block_coord_x, cur_block_coord_y + 1)) cur_block_coord_y++; else { to_bottom = TRUE; //到底 break; } break; case L: if(isCanMoveBlock(cur_block_coord_x - 1, cur_block_coord_y)) cur_block_coord_x -= 1; break; case R: if(isCanMoveBlock(cur_block_coord_x + 1, cur_block_coord_y)) cur_block_coord_x += 1; break; } if(to_bottom) { if(old_x != cur_block_coord_x || old_y != cur_block_coord_y || old_boxindex != cur_boxindex) { for(i = 0; i < 4; i++) game_arr[old_y+block[old_boxindex].a[i][1]][old_x+block[old_boxindex].a[i][0]].info = 0; for(i = 0; i < 4; i++) game_arr[cur_block_coord_y+block[cur_boxindex].a[i][1]][cur_block_coord_x+block[cur_boxindex].a[i][0]].info = BLOCK; gameShow(); //要按键之后才刷新 } to_bottom = FALSE; toBottom(cur_block_coord_x, cur_block_coord_y); gameShow();//到底 } else { if(j++ % 10 == 0) { //自动下移,要放前面, if(isCanMoveBlock(cur_block_coord_x, cur_block_coord_y + 1)) cur_block_coord_y++; else to_bottom = TRUE; //到底 } if(old_x != cur_block_coord_x || old_y != cur_block_coord_y || old_boxindex != cur_boxindex) { for(i = 0; i < 4; i++) game_arr[old_y+block[old_boxindex].a[i][1]][old_x+block[old_boxindex].a[i][0]].info = 0; for(i = 0; i < 4; i++) game_arr[cur_block_coord_y+block[cur_boxindex].a[i][1]][cur_block_coord_x+block[cur_boxindex].a[i][0]].info = BLOCK; gameShow(); //要按键之后才刷新 } } if(flashT % 100 < 2) { flashT = (flashT + 2) % 100; flashTime -= 5; if(flashTime < 30) { flashTime = 30; } } Sleep(flashTime); } } short isCanMoveBlock(short x, short y) { //是否能移动方块 short i; for(i=0; i<4; i++) if(game_arr[y+block[cur_boxindex].a[i][1]][x+block[cur_boxindex].a[i][0]].var) return FALSE; //如果该位置以及有方块填充,则不能移动 return TRUE; } void toBottom(short x, short y) { //方块到底之后的操作,1.将方块的位置的状态变为1,表示被占用。2.是否满块,消行,改变状态 3.产生新的方块 short i,j; for(i = 0; i < 4; i++) game_arr[y+block[cur_boxindex].a[i][1]][x+block[cur_boxindex].a[i][0]].var = 1; //2.是否满块,消行,改变状态 for(i = UI_HEIGHT - 2; i >= 1; i--) { //有两行是墙 ,从底开始往上搜 for(j = 1; j <= UI_WIDTH - 2; j++) { if( !game_arr[i][j].var) break;//一行有空的就跳出这个循环 ,继续搜下一行 if(j == UI_WIDTH - 2) { //一行都满了,消行,此时第i行是满行 score += 10; int h,v; for(v = i; v >= 2; v--) { //第i行开始, for(h = 1; h <= UI_WIDTH - 2; h++) { game_arr[v][h].info = game_arr[v-1][h].info; game_arr[v][h].var = game_arr[v-1][h].var; } }//要从底行重新,之后i--,i = UI_HEIGHT - 2,就会出现多行一起消时有行消不了 i = UI_HEIGHT - 1; } } } produceBlock(); } void welcometogame() { //开始界面 Pos(6,6); system("title 简易俄罗斯方块"); printf("欢迎来到俄罗斯方块游戏!"); Pos(1,12); printf("不倒翁 AIoT 创新创业协会欢迎你的到来"); Pos(2,18); printf("请开启你的体验"); Pos(6,25); system("pause"); system("cls"); } void pause() { //暂停 while(1) { Sleep(300); if(GetAsyncKeyState(VK_SPACE)) { break; } } }
2021年11月27日
58 阅读
0 评论
0 点赞
2021-11-27
[C语言] 游戏贪吃蛇
一级标题二级标题三级标题四级标题五级标题六级标题#include<stdio.h> #include<time.h> #include<windows.h> #include<stdlib.h> #define U 1 #define D 2 #define L 3 #define R 4 //蛇的状态,U:上 ;D:下;L:左 R:右 typedef struct SNAKE { //蛇身的一个节点 int x; int y; struct SNAKE *next; } snake; //全局变量// int score=0,add=1;//总得分与每次吃食物得分。 int status,sleeptime=300;//每次运行的时间间隔 snake *head, *food;//蛇头指针,食物指针 snake *q;//遍历蛇的时候用到的指针 int endgamestatus=0; //游戏结束的情况,1:撞到墙;2:咬到自己;3:主动退出游戏。 int MapWidth = 56, MapHeigth = 26; //声明全部函数// void Pos(); void creatMap(); void initsnake(); int biteself(); void createfood(); void cantcrosswall(); void snakemove(); void pause(); void gamecircle(); void welcometogame(); void endgame(); void gamestart(); void Pos(int x,int y) { //设置光标位置 COORD pos; HANDLE hOutput; pos.X = x; pos.Y = y; hOutput = GetStdHandle( STD_OUTPUT_HANDLE); SetConsoleCursorPosition(hOutput,pos); } void creatMap() { //创建地图 int i; for(i = 0; i < MapWidth + 2; i++) { //打印上下边框 Pos(i,0); printf("$"); Pos(i, MapHeigth + 1); printf("$"); } for(i = 1; i < MapHeigth + 2; i++) { //打印左右边框 Pos(0,i); printf("$"); Pos(MapWidth + 1,i); printf("$"); } } void initsnake() { //初始化蛇身 snake *tail; int i; tail = (snake*)malloc(sizeof(snake));//从蛇尾开始,头插法,以x,y设定开始的位置// tail->x = 24; tail->y = 5; tail->next = NULL; for(i=1; i<=4; i++) { head = (snake*)malloc(sizeof(snake)); head->next = tail; head->x = 24 + i; head->y = 5; tail = head; } while(tail != NULL) { //从头到为,输出蛇身 Pos(tail->x, tail->y);// 移动光标 printf("#"); tail = tail->next; } } int biteself() { //判断是否咬到了自己 snake *self; self = head->next; while(self != NULL) { if(self->x == head->x && self->y == head->y) { return 1; } self = self->next; } return 0; } void createfood() { //随机出现食物 snake *food_1; srand((unsigned)time(NULL)); food_1 = (snake*)malloc(sizeof(snake)); // 保证食物在地图中 food_1->x = rand() % MapWidth + 1; food_1->y = rand() % MapHeigth + 1; q = head; //检查蛇身是否与食物重合 while(q->next != NULL) { if(q->x == food_1->x && q->y==food_1->y) { free(food_1); createfood(); } q = q->next; } // 出现食物 Pos(food_1->x,food_1->y); food = food_1; printf("@"); } void cantcrosswall() { //不能穿墙 if(head->x == 0 || head->x == MapWidth ||head->y==0 || head->y == MapHeigth) { endgamestatus=1; endgame(); } } void snakemove() { //蛇前进,上U,下D,左L,右R cantcrosswall(); if(biteself()) { //判断是否会咬到自己 endgamestatus = 2; endgame(); } snake * nexthead; nexthead=(snake*)malloc(sizeof(snake)); if(status==U) {// 向上移动 nexthead->x=head->x; nexthead->y=head->y-1; }else if(status==D) {// 向下移动 nexthead->x=head->x; nexthead->y=head->y+1; }else if(status==L) {// 向左移动 nexthead->x=head->x-1; nexthead->y=head->y; }else if(status==R) {// 向右移动 nexthead->x=head->x+1; nexthead->y=head->y; } if(nexthead->x == food->x && nexthead->y==food->y) { //如果下一个有食物// nexthead->next = head; head = nexthead; q = head; while(q!=NULL) { Pos(q->x,q->y); printf("#"); q=q->next; } score = score + add; createfood(); } else { //如果没有食物// nexthead->next = head; head = nexthead; q = head; while(q->next->next!=NULL) { Pos(q->x,q->y); printf("#"); q=q->next; } Pos(q->next->x,q->next->y); printf(" "); free(q->next); q->next=NULL; } } void pause() { //暂停 while(1) { Sleep(300); if(GetAsyncKeyState(VK_SPACE)) { break; } } } void gamecircle() { //控制游戏 Pos(64,15); printf("不能穿墙,不能咬到自己"); Pos(64,16); printf("用↑.↓.←.→分别控制蛇的移动."); Pos(64,17); printf("ESC :退出游戏.space:暂停游戏."); status=R; while(1) { Pos(64,10); printf("得分:%d ",score); Pos(64,11); printf("每个食物得分:%d分",add); Sleep(sleeptime); if(GetAsyncKeyState(VK_UP) && status != D) { status = U; } else if(GetAsyncKeyState(VK_DOWN) && status!=U) { status=D; } else if(GetAsyncKeyState(VK_LEFT)&& status!=R) { status=L; } else if(GetAsyncKeyState(VK_RIGHT)&& status!=L) { status=R; } else if(GetAsyncKeyState(VK_SPACE)) { pause(); } else if(GetAsyncKeyState(VK_ESCAPE)) { endgamestatus=3; break; } snakemove(); } } void welcometogame() { //开始界面 Pos(40,12); system("title 贪吃蛇"); Pos(40,15); printf("不倒翁 AIoT 创新创业协会欢迎你的到来"); Pos(40,18); printf("开启你的体验"); Pos(40,25); system("pause"); system("cls"); } void endgame() { //结束游戏 system("cls"); Pos(24,12); if(endgamestatus==1) { printf("对不起,您撞到墙了。游戏结束."); } else if(endgamestatus==2) { printf("对不起,您咬到自己了。游戏结束."); } else if(endgamestatus==3) { printf("您的已经结束了游戏。"); } Pos(24,13); printf("您的得分是%d\\n",score); exit(0); } void gamestart() { //游戏初始化 system("mode con cols=100 lines=30"); welcometogame(); creatMap(); initsnake(); createfood(); } int main() { gamestart(); gamecircle(); endgame(); return 0; }
2021年11月27日
108 阅读
0 评论
0 点赞