|
|
@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
void printNode(TestNode p,int n)//输出第n道题题目
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("(%d)",n);
|
|
|
|
|
|
|
|
printf("%s\n",p.subject);
|
|
|
|
|
|
|
|
printf(" A.%s ",p.option1);
|
|
|
|
|
|
|
|
printf(" B.%s \n",p.option2);
|
|
|
|
|
|
|
|
printf(" C.%s ",p.option3);
|
|
|
|
|
|
|
|
printf(" D.%s ",p.option4);
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Status Match(TestNode p,char m)//判断m是否为p题目的答案,若是返回1,否则返回0
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(m==p.result)
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
else return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void answer(int sum)//开始答题
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int i,score=0,num;
|
|
|
|
|
|
|
|
char r;
|
|
|
|
|
|
|
|
for(i=1;i<=sum;i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
num=rand()%sum;//随机选题
|
|
|
|
|
|
|
|
printNode(Testquestions[num],i);
|
|
|
|
|
|
|
|
printf("\n 请输入答案:");
|
|
|
|
|
|
|
|
scanf("%c",&r);
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
if(Match(Testquestions[num],r))//调用Match函数判断是否为题目的答案
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n 答案正确! \n");
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
score++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else printf("\n 答案错误! \n");
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n 你的总成绩为:%d \n",score);//输出你的成绩
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|