此程序实现的是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;
}

 

 

 

2015.3.6的程序实践

 

相关文章:

  • 2021-10-02
  • 2022-02-06
  • 2021-10-15
  • 2021-06-08
  • 2021-07-10
  • 2021-11-08
  • 2021-11-13
  • 2021-09-29
猜你喜欢
  • 2021-12-20
  • 2022-01-05
  • 2021-11-19
  • 2021-09-16
  • 2021-08-25
  • 2021-09-03
相关资源
相似解决方案