标签:依次 掌握 system src srand == 分享 rand bre
设计思路
1.随机产生三个数
2.第二个数除以四产生余数
3.剩下两个数作运算
4.第二个数得到的余数用作对应出运算符
5.将三个依次输出
#include<iostream>
#include<string>
#include<time.h>
using namespace std;
int main()
{
srand((unsigned)time(NULL));
int a,b,c;
string x;
for (int i=0; i < 30; i++)
{
a = rand() % 100;
b = rand() % 100;
c = rand() % 4;
switch (c)
{
case 0:x = "+"; break;
case 1:x = "-"; break;
case 2:x = "*"; break;
case 3:x = "/";
}
cout << a << " " << x << " " << b+1 << " =" << " ";
if(i%3==0)
cout<<endl;
}
system ("pause");
return 0;
}
总结:对程序语言的掌握仍然需要提升
标签:依次 掌握 system src srand == 分享 rand bre
原文地址:https://www.cnblogs.com/try-my--best/p/9753905.html