我需要帮助在 C++ 中解决这个问题,无需更改运算符和值,只需将括号放在正确的位置即可

问题描述 投票:0回答:1

我需要解决这个问题,无需更改任何内容,只需放入括号即可得到答案 10000

只需要使用括号输出,无需将任何内容更改为 10000

#include <iostream>
using namespace std;
int main()
{
int a = 10;
int b = 20;

cout << a + b * a + b + a * a * a << "\n";       // 10000

} 
c++ integer operators
1个回答
0
投票

((10 + 20) * (10 + 20) + (10 * 10)) * 10 这将为您提供答案。查看 C++ 中的运算符优先级和 BODMAS 规则。

© www.soinside.com 2019 - 2024. All rights reserved.