源程序代码:
#include<stdio.h>
#include<stdlib.h>
int main()
{
int
i,a,b,u,v,c,d,g,h,x,y,m,n=0,right=0,wrong=0;
char p;
printf("小宝贝们你们好!\n\n");
for(i=0;i<10;i++)
{
a=rand()%(100-51+1)+51;
b=rand()%(50-10+1)+10;
g=rand()%(90-0+1)+0;
h=rand()%(10-1+1)+1;
{
printf("请您选择题型:\n\n");
printf("加法请输1\n\n");
printf("减法请输2\n\n");
printf("乘法请输3\n\n");
printf("除法请输4\n\n");
scanf("%d",&m);
printf("\t\t%d.",i+1);
if(m==1)
{
printf("\t%d+%d=",a,b);
scanf("%d",&c);
if(a+b==c)
{
printf("\t\t\t回答正确\n\n");
right++;
}
else
{
printf("\t\t\t回答错误\n\n");
wrong++;
}
}
if(m==2)
{
printf("\t%d-%d=",a,b);
scanf("%d",&d);
if(a-b==d)
{
printf("\t\t\t回答正确\n\n");
right++;
}
else
{
printf("\t\t\t回答错误\n\n");
wrong++;
}
}
if(m==3)
{
printf("\t%d*%d=",g,h);
scanf("%d",&x);
if(g*h==x)
{
printf("\t\t\t回答正确\n\n");
right++;
}
else
{
printf("\t\t\t回答错误\n\n");
wrong++;
}
}
if(m==4)
{
while(n<1000)
{
u=rand()%(100-10+1)+1;
v=rand()%(100-10+1)+1;
if(u%v==0)
{
printf("\t%d/%d=",u,v);
scanf("%d",&y);
if(u/v==y)
{
printf("\t\t\t回答正确\n\n");
right++;
}
else
{
printf("\t\t\t回答错误\n\n");
wrong++;
}
break;
}
else
n++;
}
}
}
}
printf("答题完毕!\n\n");
printf("您共答题个数:%d\n",i);
printf("正确个数:%d\n",right);
printf("错误个数:%d\n",wrong);
scanf("%d",&p);
}
来源:https://www.cnblogs.com/tengda123/p/10246358.html