求解为什么score()函数进不去啊
#include<stdio.h>#include<windows.h> //问题是怎么调用score函数进行游戏
#include<iostream>
#include<stdlib.h>
int sec,t;
static int scores[3]={0};
int timeend(int); //时间控制程序
void highest(); //最高分显示程序
void score(int); //显示分数程序
void compair(int p); //比较大小
int main()
{
printf("choose how long you want to play(10 or 30 or 60) , input it\n");
scanf("%d",&sec);
t=sec;
timeend(sec),score(sec);
if(timeend(sec)==0)
printf("input 5 to restart\n");
return 0;
}
int timeend(int) //时间控制程序
{
int time;
for(;sec>=0;sec--)
{
printf("you have %2d seconds",sec);
Sleep(1000);
system("cls");
}
return 0;
}
void score(int) //显示分数程序
{
char button;
for(;sec>=0;)
{
scanf("%c",button); //输入字符5则分数加一
if (t==10)
{
while(button=='5')
{
scores[0]++;
printf("%d",scores[0]);
compair(scores[0]);
break;
}
}
if (t==30)
{
while(button=='5')
{
scores[1]++;
printf("%d",scores[1]);
compair(scores[1]);
break;
}
}
if (t==60)
{
while(button=='5')
{
scores[2]++;
printf("%d",scores[2]);
compair(scores[2]);
break;
}
}
button='0';
}
}
void highest()
{
int model;
printf("what is the highest type ? input it\n");
scanf("%d",&model);
if (model==10)
printf("10 seconds , the highest score is %2d",scores[0]);
else if (model==30)
printf("30 seconds , the highest score is %2d",scores[1]);
else if (model==60)
printf("60 seconds , the highest score is %2d",scores[2]);
}
void compair(int p)
{
if (sec==10&&p>=scores[0])
{
scores[0]=p;
exit (0);
}
else if (sec==30&&p>=scores[1])
{
scores[1]=p;
exit (0);
}
else if (sec==60&&p>=scores[2])
{
scores[2]=p;
exit (0);
}
}