From 272e9b730bbcc39a0b58e1e91b29844f26f5b512 Mon Sep 17 00:00:00 2001 From: "18408200211@stu.hut.edu.cn" <18408200211@stu.hut.edu.cn> Date: Thu, 10 Jan 2019 09:19:41 +0800 Subject: [PATCH] 3 commit --- 输出试题函数以及判题函数.c | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 输出试题函数以及判题函数.c 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ɼ + } +