当前位置:Gxlcms > PHP教程 > 201306114357-实验1,201306114357-实验_PHP教程

201306114357-实验1,201306114357-实验_PHP教程

时间:2021-07-01 10:21:17 帮助过:6人阅读

201306114357-实验1,201306114357-实验


#include
#include
#include
main()
{
int a,b,c;
float resultTrue=0,n;
char op;
srand(time(NULL));
do
{
a=rand()%10+1;
b=rand()%10+1;
c=rand()%4+1;
switch(c%4)
{
case 0:
{
op='+';
break;
}
case 1:
{
op='-';
break;
}
case 2:
{
op='*';
break;
}
case 3:
{
op='/';
break;
}
}
printf("%d%c%d=\n",a,op,b);
switch(op)
{
case '+':
{
resultTrue=a+b;
break;
}
case '-':
{
resultTrue=a-b;
break;
}
case '*':
{
resultTrue=a*b;
break;
}
case '/':
{
resultTrue=a/b;
break;
}
}
printf("请输入正确答案(1000为结束):");
scanf("%f",&n);
if(n!=0)
{
if(resultTrue!=n)
{
printf("答案错误,答案为%d\n",resultTrue);
}
if(resultTrue==n)
{
printf("答案正确\n");
}
}
if(n==10000)
{
return;
}
}while(1);
}

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/977083.htmlTechArticle201306114357-实验1,201306114357-实验 #includestdio.h #include stdlib.h #include time.h main() { int a,b,c; float resultTrue=0,n; char op; srand(time(NULL)); do { a=rand()%10+...

人气教程排行