写一个程序求五个数的最大值
时间: 2023-05-11 13:04:08 浏览: 58
可以使用以下代码来求五个数的最大值:
```
#include <iostream>
using namespace std;
int main() {
int a, b, c, d, e;
cout << "请输入五个整数:" << endl;
cin >> a >> b >> c >> d >> e;
int max = a;
if (b > max) max = b;
if (c > max) max = c;
if (d > max) max = d;
if (e > max) max = e;
cout << "最大值为:" << max << endl;
return 0;
}
```
这个程序会让用户输入五个整数,然后找出其中的最大值并输出。
相关问题
python写一个求三个数最大值的程序
def max_num(a,b,c):
if a>b and a>c:
return a
elif b>a and b>c:
return b
else:
return c
print(max_num(4,8,2)) # 输出 8
用python写一个求两个数最大值的程序
好的,这个问题我可以回答。以下是一个用 Python 编写的求两个数最大值的程序:
```
a = float(input("请输入第一个数:"))
b = float(input("请输入第二个数:"))
if a > b:
print("最大值是:", a)
else:
print("最大值是:", b)
```
这个程序会先让用户输入两个数,然后通过 if 语句判断哪个数更大,最后输出最大值。希望这个回答能够帮到你。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)