#include #include #include int main(void) { srand(time(0)); printf("小学生测验\n"); int i,t,k=0,a,b,s=0; for(i=0;i<10;i++) { a=rand()%51; b=rand()%51; while(a+b>50) //使k的最大值小于50 { k=a+b; if(k>50) { a=rand()%51; b=rand()%51; } } if(ba,使用减法。 printf("%d-%d=",b,a); scanf("%d",&t); if(t==k) //学生第一次输入正确答案得10分。 { s+=10; } else { printf("答案错误,请重新输入"); scanf("%d",&t); if(t==k) //学生第二次输入正确答案得7分。 { s+=7; } else { printf("答案错误,请重新输入"); scanf("%d",&t); if(t==k) //学生第三次输入正确答案得5分。 { s+=5; } else //学生三次输入的答案都不正确,得0分。 { s+=0; printf("正确答案为%d\n",k); } } } } } printf("%d ",s); //输出该学生的最终成绩并给他评定级别。 if(s<60) printf("TAY AGAAIN "); else if(s>=60&&s<=70) printf("PASS "); else if(s>70&&s<=80) printf("OK "); else if(s>80&&s<=90) printf("GOOD "); else printf("SMART "); return 0; }