c++里面的一道编程题目,知道答案的麻烦告诉下,谢谢!

2025-01-06 02:52:32
推荐回答(2个)
回答1:

#include
#include
#include
using namespace std;

int main()
{
int oper;//操作符 0 为加法,1为减法,2为乘法,3为除法
char operchar;//运算符的字符形式
double num1,num2,result,userResult;
srand(unsigned(time(NULL))); //随机种子
oper = rand()%4;
num1 = rand()%100;
num2 = rand()%100;
//如果除数为0则重新产生随机数
if (oper == 3)
{
while(num2==0)
{
num2 = rand()%100;
}
}
switch (oper)
{
case 0:result = num1+num2;operchar='+';break;
case 1:result = num1-num2;operchar='-';break;
case 2:result = num1*num2;operchar='*';break;
case 3:result = num1/num2;operchar='/';break;
default :break;
}
cout< cout< cin>>userResult;
if ( abs(result - userResult) <0.01)
cout <<'答案正确!'< else
cout <<'答案错误!正确答案为:'< return 0;
}

百度不允许输入双引号,我把我程序中的双引号都改为了单引号,你改改就可以了

回答2:

using namespace std;

int main()
{
double random(double,double);
srand(unsigned(time(0)));

int a=int(random(0,10));
int b=int(random(0,10));
int c=int(random(0,3));
int z=0;
int input=0;
cout<<

晕死 传不上来 直接找我要 43628418