|
|
#include"main.h"
|
|
|
|
|
|
test(int v){ //测验函数
|
|
|
|
|
|
date max;
|
|
|
|
|
|
int a,b;
|
|
|
int sign;
|
|
|
int scores=0;
|
|
|
int ran=100;
|
|
|
int sta=0;
|
|
|
double time;
|
|
|
char question[22],wro_set[222];
|
|
|
char truth[11],answer[11];
|
|
|
|
|
|
if(range==1) ran=1000;
|
|
|
|
|
|
clock_t start,end;
|
|
|
|
|
|
printf("\n\n\n\n\n\n");
|
|
|
|
|
|
for(int i=3;i>0;i--){
|
|
|
printf("\t\t\t测验将在%d秒后开始\n\n",i); if(voice==1) printf("\a");
|
|
|
sleep(1);
|
|
|
}
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
start=clock();
|
|
|
|
|
|
for(int i=0;i<10;i++){ //随机出题
|
|
|
|
|
|
printf("\n\n\n\n\n\n\n\t\t\t(输入exit直接退出测验)");
|
|
|
|
|
|
if(kind==0){
|
|
|
|
|
|
do{
|
|
|
|
|
|
a=rand()%(ran-ran/10)+ran/10+1;
|
|
|
b=rand()%(ran-ran/10)+ran/10+1;
|
|
|
sign=rand()%2;
|
|
|
if(sign==0) sign=-1;
|
|
|
|
|
|
}while((a+sign*b)<ran/10||(a+sign*b)>ran);
|
|
|
|
|
|
sprintf(truth,"%d",a+sign*b);
|
|
|
|
|
|
if(sign==1) sprintf(question,"\n\n\t\t\t第%-2d题:%d+%d=",i+1,a,b);
|
|
|
if(sign==-1) sprintf(question,"\n\n\t\t\t第%-2d题:%d%d=",i+1,a,-1*b);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
do{
|
|
|
|
|
|
a=rand()%(ran-4)+3;
|
|
|
b=rand()%(ran-4)+3;
|
|
|
sign=rand()%2;
|
|
|
if(sign==0){
|
|
|
if((a/b)>=3&&(a/b)<=ran&&(a%b==0))
|
|
|
break;
|
|
|
}else{
|
|
|
if((a*b)>=10&&(a*b)<=ran)
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
}while(1);
|
|
|
|
|
|
if(sign==0) sprintf(truth,"%d",a/b);
|
|
|
else sprintf(truth,"%d",a*b);
|
|
|
|
|
|
if(sign==0) sprintf(question,"\n\n\t\t\t第%-2d题:%d/%d=",i+1,a,b);
|
|
|
else sprintf(question,"\n\n\t\t\t第%-2d题:%d*%d=",i+1,a,b);
|
|
|
|
|
|
}
|
|
|
|
|
|
printf("%s",question);
|
|
|
|
|
|
for(int j=2;j>=0;j--){
|
|
|
|
|
|
|
|
|
printf("\n\n\t\t\t您的答案是:");
|
|
|
|
|
|
scanf("%s",&answer); if(voice==1) printf("\a");
|
|
|
|
|
|
if((strcmp(answer,"exit"))==0) goto exit;
|
|
|
|
|
|
if((strcmp(answer,truth))==0){
|
|
|
|
|
|
if(j==2) scores+=10;
|
|
|
if(j==1) scores+=7;
|
|
|
if(j==0) scores+=5;
|
|
|
printf("\t\t\t答案正确\n\n");
|
|
|
break;
|
|
|
|
|
|
}else{
|
|
|
printf("\t\t\t答案错误 您还有%d次机会",j);
|
|
|
if(j==0){
|
|
|
sta=1;
|
|
|
strcat(wro_set,question);
|
|
|
strcat(wro_set,truth);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
}
|
|
|
|
|
|
end=clock();
|
|
|
time=(float)(end-start)/CLK_TCK;
|
|
|
|
|
|
|
|
|
if(sta==1){
|
|
|
|
|
|
system("cls");
|
|
|
printf("\n\n\n\n\n\n\t\t\t本次测验错题%s",wro_set);
|
|
|
printf("\n\n\t\t\t按下任意键继续");
|
|
|
getch();
|
|
|
system("cls");
|
|
|
|
|
|
}
|
|
|
|
|
|
printf("\n\n\n\n\n\n\t\t\t测验结束,您的成绩是:\n\n\t\t\t%d分 ",scores);
|
|
|
switch(scores/10){ //等级判定
|
|
|
|
|
|
case 10:{
|
|
|
printf("满分");
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
case 9:{
|
|
|
printf("优秀");
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
case 8:{
|
|
|
printf("良好");
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
case 7:
|
|
|
case 6:{
|
|
|
printf("及格");
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
default :{
|
|
|
printf("不及格");
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
printf(" 用时%.2f秒\n\n",time);
|
|
|
|
|
|
printf("\t\t\t输入你的名字后返回菜单\n\n");
|
|
|
printf("\t\t\t君的名字:");
|
|
|
scanf("%s",&dates[dif][10].name); if(voice==1) printf("\a");
|
|
|
|
|
|
dates[dif][10].scores=scores;
|
|
|
dates[dif][10].time =time;
|
|
|
|
|
|
for(int i=0;i<10;i++){
|
|
|
|
|
|
max=dates[dif][i];
|
|
|
|
|
|
for(int j=i+1;j<11;j++){
|
|
|
|
|
|
if(max.scores<dates[dif][j].scores){
|
|
|
|
|
|
max =dates[dif][j];
|
|
|
dates[dif][j]=dates[dif][i];
|
|
|
dates[dif][i]=max;
|
|
|
|
|
|
}
|
|
|
|
|
|
if(max.scores==dates[dif][j].scores){
|
|
|
|
|
|
if(max.time>dates[dif][j].time){
|
|
|
|
|
|
max =dates[dif][j];
|
|
|
dates[dif][j]=dates[dif][i];
|
|
|
dates[dif][i]=max;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
exit:
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
}
|