You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
system1/输出试题函数以及判题函数.c

43 lines
880 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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);//输出你的成绩
}