一年前写的小游戏,当时感觉小有成就,现在发现缺陷真的很多。不禁感叹,当时为什么会用那么多goto呢。在这里真的建议大家不要用goto。只是现在懒得改了,毕竟是小程序。贴出来供大家参考。如果有时间后序再添加注释。如有问题欢迎评论。
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#include <time.h>
#define max 10
int x, y, step, label = 0;
typedef struct score {
int steps, steps2;
double times;
char name[18];
}score;
score sco[max + 1];
char ch, buff[3];
bool flag, flag1 = false;
clock_t start, finish;
bool over(){
system("cls");
printf("\n\n\n\n\t\t\t您共用了 %d 步 ,耗时 %.3f 分钟\n", step, (double)(finish - start) / 40000);
system("pause");
system("cls");
printf("\n\n\n\n\n\n\n\n\t******************* 您是否重新开始游戏 (Y/N) ? *******************\n\n");
scanf("%s", buff);
ch = buff[0];
if (ch != 'n'&&ch != 'N') {
return false;
}
else {
printf("\n\n\n\n\t++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
printf("\t+++++++++++++++++++++++++ 感谢您的使用 +++++++++++++++++++++++++\n", step);
printf("\t+++++++++++++++++++