diff --git a/输出试题函数以及判题函数.c b/输出试题函数以及判题函数.c new file mode 100644 index 0000000..bc69984 --- /dev/null +++ b/输出试题函数以及判题函数.c @@ -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);//ijɼ + } +