abc输入三个整数怎么编程序

时间:2025-03-05 07:11:00 明星趣事

```cpp

include

using namespace std;

int main() {

int a, b, c;

cout << "请输入三个整数,用空格隔开: ";

cin >> a >> b >> c;

int max = a;

if (b > max) {

max = b;

}

if (c > max) {

max = c;

}

cout << "最大的数是: " << max << endl;

return 0;

}

```

这个程序首先包含了`iostream`头文件,以便使用输入输出流。然后,在`main`函数中,我们声明了三个整数变量`a`、`b`和`c`,并使用`cout`提示用户输入三个整数,使用`cin`读取用户输入的值。

接下来,我们假设`a`是最大值,并将其存储在变量`max`中。然后,我们使用两个`if`语句分别检查`b`和`c`的值,如果它们中的任何一个比`max`大,我们就更新`max`的值。

最后,我们使用`cout`输出找到的最大值。