first commit

master
p72498163 6 years ago
parent 5516948811
commit 7b3fdef8d8

@ -0,0 +1,116 @@
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
int question( int i)
{
int a,b,j,m;
for( i = i;i<100;i++ )
{
loop:
{
a=rand()%51;
b=rand()%51;//rand()%100表示取50以内的随机数
j=rand()%2;//j的值决定加减法
}
if(j==0)
{
m=a+b;
if(m<=50)
{
printf("%d+%d=\n",a,b);
}
else
goto loop;
}
else
{
m=a-b;
if(m<=50&&m>=0)
{
printf("%d-%d=\n",a,b);
}
else
goto loop;
}
break;
}
return m;
}
int main()
{
int ordinal=1;
int modelanswer=0;
int studentanswer=0;
char str[20];
int grade=0;
int n;
printf("\n");
printf("============================================================\n");
printf("====================50以内加减法检测系统====================\n");
printf("============================================================\n");
printf("\n");
printf("请输入你的名字:\n");
scanf("%s",str);
printf("\n你好呀,%s小朋友欢迎进入50以内加减法检测系统。\n",str);
printf("每道题你有三次答题机会,如果三次机会结束则直接给出正确答案。\n");
printf("\n测试结束后会给出你的成绩以及相应评级。\n");
printf("\n");
printf("======================要注意细心哦~=========================\n\n");
for(n=1;n<11;n++)
{
printf("\n第%d道题\n",n);
modelanswer=question(n);
printf("请输入答案:");
scanf("%d",&studentanswer);
if(studentanswer==modelanswer)
{
printf("回答正确,请继续加油哦。\n");
grade=grade+10;
}
else
{
printf("回答错误,请好好思考。你还有两次机会。\n");
printf("请输入答案:");
scanf("%d",&studentanswer);
if(studentanswer==modelanswer)
{
printf("回答正确,请继续加油哦。\n");
grade=grade+7;
}
else
{
printf("回答错误,请好好思考。你还有一次机会。\n");
printf("请输入答案:");
scanf("%d",&studentanswer);
if(studentanswer==modelanswer)
{
printf("回答正确,请继续加油哦。\n");
grade=grade+5;
}
else
{
printf("回答错误。正确答案是:%d\n",modelanswer);
grade=grade+0;
}
}
}
}
return 0;
}

Binary file not shown.
Loading…
Cancel
Save