second commit

master
2212907042@qq.com 6 years ago
parent ee3fdf25c0
commit f88a2756e4

@ -1,9 +1,11 @@
#include <stdio.h> #include <stdio.h>
#include<stdlib.h>
#include<time.h>
struct Student struct Student
{ {
char cSchool[15]; char cSchool[15];
char cGrade[15]; char cGrade[15];
char cName[15]; char cName[15];
}; };
@ -16,7 +18,7 @@ int k=0,grade; /*
int main() int main()
{ {
struct Student student1; struct Student student1;
printf("****预祝测试顺利****\n\n"); printf("****预祝测试顺利****\n\n");
printf("学校:"); printf("学校:");
scanf("%s",&student1.cSchool); scanf("%s",&student1.cSchool);
@ -24,10 +26,10 @@ int main()
scanf("%s",&student1.cGrade); scanf("%s",&student1.cGrade);
printf("姓名:"); printf("姓名:");
scanf("%s",&student1.cName); scanf("%s",&student1.cName);
printf("\n"); printf("\n");
printf("请回答下面十道题目\n"); printf("请回答下面十道题目\n");
do{ do{
int i=test(); int i=test();
if(i==-1) if(i==-1)
@ -39,7 +41,7 @@ int main()
else if(grade>=70&&grade<80) else if(grade>=70&&grade<80)
printf("-------OK"); printf("-------OK");
else if(grade>=60&&grade<70) else if(grade>=60&&grade<70)
printf("-------PASS"); printf("-------PASS");
else else
printf("-------TRY AGAIN"); printf("-------TRY AGAIN");
break; break;
@ -65,17 +67,17 @@ int test()
{ {
printf("\n所有题目已答完,你的成绩:%d分",grade); printf("\n所有题目已答完,你的成绩:%d分",grade);
return -1; return -1;
} }
else if(c==0) else if(c==0)
{ {
printf("第%d题:%d+%d=",k,a,b); printf("第%d题:%d+%d=",k,a,b);
return a+b; return a+b;
} }
else if(c==1) else if(c==1)
{ {
printf("第%d题:%d-%d=",k,a,b); printf("第%d题:%d-%d=",k,a,b);
return a-b; return a-b;
} }
return -1; return -1;
} }
@ -85,41 +87,42 @@ int checknum(int a,int b) /*
return 0; return 0;
else else
return 1; return 1;
} }
int checkresult(int result) int checkresult(int result)
{ {
int i; int i;
for(i=1;i<4;i++) for(i=1;i<4;i++)
{ {
scanf("%d", &x); scanf("%d", &x);
if (x!=result) if (x!=result)
{ {
if (i==3) if (i==3)
{ {
if (c==0){ if (c==0){
printf("三次回答错误,正确答案是%d\n",a+b); printf("三次回答错误,正确答案是%d\n",a+b);
} }
else { else {
printf("三次回答错误,正确答案是%d\n",a-b); printf("三次回答错误,正确答案是%d\n",a-b);
} }
return 0; return 0;
} }
printf("回答错误,请再次输入:"); printf("回答错误,请再次输入:");
} }
else{ else{
switch(i){ switch(i){
case 1:grade+=10; case 1:grade+=10;
break; break;
case 2:grade+=7; case 2:grade+=7;
break; break;
case 3:grade+=5; case 3:grade+=5;
break; break;
default:grade+=0; default:grade+=0;
break; break;
}
return 0;
} }
return 0;
}
} }
return 0; return 0;
} }

Loading…
Cancel
Save