//Main函数调用
#include <stdio.h>
#include <string.h>
#include "Root.h"
int maxNum = 0;//最大值
int score = 0;//当前得分
int hisScore = 0;//历史最高分
int main(int argc, const char * argv[]) {
int numbers[X][Y]={ 0};
int * p = *numbers;
randNum(p,1);//首次登陆显示两个随机数
randNum(p,1);
show(p);
maxNum = selMax(p,&maxNum);
read_file(&maxNum, &hisScore);
showMain(numbers,p,&maxNum,&score,&hisScore);
printf("max = %d\n",maxNum);
return 0;
}
//
#include "Root.h"
void showMain(int (*numbers)[],int *p,int *maxNum,int *score,int *hisScore)
{
int cond=0;//循环条件
int zt = 0;//状态
char gesture[2];//滑动指令
do {
printf("W(上)、S(下)、A(左)、D(右)\n");
printf("MAX = %d\t当前得分=%d\t历史最高分=%d\n",*maxNum,*score,*hisScore);
printf("指令:");
scanf("%s",gesture);
if (strcmp(gesture, "W") == 0
|| strcmp(gesture, "w") == 0
|| strcmp(gesture, "S") == 0
|| strcmp(gesture, "s") == 0
|| strcmp(gesture, "A") == 0
|| strcmp(gesture, "a") == 0
|| strcmp(gesture, "D") == 0
|| strcmp(gesture, "d") == 0) {
zt = changeXY(numbers,gesture,score,hisScore);
if (zt == 1) {
randNum(p,1);
show(p);
int cd = selMax(p,maxNum);
//存储最大值和历史最高分
if (*score > *hisScore
|| cd > *maxNum) {
*maxNum = cd;
write_file(maxNum,score);//保存历史最高分
}