程序源代码:

#include <stdio.h>
#include <stdlib.h>
void main()
{
int n,a,b,i;
int answer;
for (i=0;i<100;i++)
{ a=rand()%100;
b=rand()%100;
n=rand()%4;

switch(n)
{case 0:printf("%d+%d=",a,b);
answer=a+b;
break;
case 1:
while(a-b<0)
{a=rand()%100;
b=rand()%100;
}
printf("%d-%d=",a,b);
answer=a-b;
break;
case 2:printf("%d*%d=",a,b);
answer=a*b;
break;
case 3:
while(a%b!=0)
{a=rand()%100;
b=rand()%100;}
printf("%d/%d=",a,b);
answer=a/b;
break;
}
printf("\t\t\t\t\t\t\t\t\%d\n",answer);
}
}

 

运行结果:

小学生整数四则运算

相关文章:

  • 2021-10-23
  • 2021-10-10
  • 2021-07-18
  • 2021-12-31
猜你喜欢
  • 2021-05-19
相关资源
相似解决方案