题目:致力于解决二柱爸爸的第一个问题,出30道100以内的加减乘除给儿子做
思路:随机产生运算的两个100以内的整数x和y,m也是随机数,通过用m来控制+,-,*,/的随机出现,用for来控制循环次数30,即可实现;另外调用函数实现这些功能,便于在解决二柱爸爸今后要解决的问题,添加其他的功能实现。
主程序:
#include<iostream.h>#include<time.h>#include<stdlib.h>#include<stdio.h>void chuti(){ int x,y; int m; x=rand()0; y=rand()0; m=rand()%4; if(m==0) cout<<x<<'+'<<y<<'='<<endl; if(m==1) cout<<x<<'-'<<y<<'='<<endl; if(m==2) cout<<x<<'*'<<y<<'='<<endl; if(m==3) cout<<x<<'/'<<y<<'='<<endl;}int main(){ int i; for(i=0;i<30;i++) chuti(); cout<<"Finished!Congratulations!"; return 0;}
转载于:https://www.cnblogs.com/wantong/p/4321502.html
相关资源:各显卡算力对照表!