20分钟内写一个100以内的随机四则用算

C++程序源代码:

#include<iostream>

#include<ctime>

using namespace std;

int main()

{  

int i,j,k;  

srand((unsigned) time(NULL));

 for(int a=0 ;a<30;a++)  

{  

 i=rand()%100;   

j=rand()%100;   

k=rand()%4;

  if (k==1)    

cout<<i<<"+"<<j<<"="<<endl;   

if (k==2)    

cout<<i<<"-"<<j<<"="<<endl;   

if (k==3)    

cout<<i<<"*"<<j<<"="<<endl;   

if (k==0)    

cout<<i<<"/"<<j<<"="<<endl;    

}  

return 0;

}

20分钟内没有完成是因为rand()函数不熟练,练习不多。

相关文章:

  • 2021-10-08
  • 2022-12-23
  • 2022-01-31
  • 2022-02-12
  • 2021-06-05
  • 2021-08-16
  • 2021-05-29
  • 2021-09-10
猜你喜欢
  • 2021-08-16
  • 2022-12-23
  • 2022-01-22
  • 2021-12-29
  • 2022-01-24
  • 2021-07-01
相关资源
相似解决方案