此程序实现的是200以内的随机整数的四则运算
代码:
#include<iostream.h>
#include<stdlib.h>
int main()
{
int i,a,b,c,k;
for (i=0;i<=29;i++)
{
a=rand()%200;
b=rand()%200;
if(b>a)
{
c=a;
a=b;
b=c;
}
k=rand()%4;
if(k==0)
cout<<a<<"+"<<b<<"="<<endl;
if(k==1)
cout<<a<<"-"<<b<<"="<<endl;
if(k==2)
cout<<a<<"*"<<b<<"="<<endl;
if(k==3)
cout<<a<<"/"<<b<<"="<<endl;
}
return 0;
}