四则运算
我在写这些代码时借鉴了https://zhidao.baidu.com/question/646917167186581165.html,并进行了改动
#include <stdio.h>
#include <stdlib.h>
#include <iostream.h>
#include <conio.h>
#include <time.h>
void main()
{
int a,b,z;
int i=0;
int result;
srand((unsigned)time(NULL));
for(i=0;i<10;i++)
{
a=rand()%10;
b=rand()%10;
z=rand()%4;
printf("%d",a);
switch(z)
{
case 0:
printf("+");
result=a+b;
break;
case 1:
printf("-");
result=a-b;
break;
case 2:
printf("*");
result=a*b;
break;
case 3:
printf("/");
result=a/b;
break;
}
printf("%d=",b);
printf("\n");
}
}