编写一个程序求3个整数中最大的那个数
时间: 2024-05-03 10:20:36 浏览: 16
你好,这是一个求3个整数中最大的那个数的程序:
```
#include <iostream>
using namespace std;
int main()
{
int num1, num2, num3, max;
cout << "请输入三个整数,用空格隔开:" << endl;
cin >> num1 >> num2 >> num3;
max = num1;
if (num2 > max) {
max = num2;
}
if (num3 > max) {
max = num3;
}
cout << "最大的整数是:" << max << endl;
return 0;
}
```
希望能解决你的问题。
相关问题
编写一个C语言程序,求出三个整数中最大的数
```c
#include <stdio.h>
int main() {
int a, b, c;
printf("请输入三个整数:\n");
scanf("%d%d%d", &a, &b, &c);
int max = a;
if (b > max) {
max = b;
}
if (c > max) {
max = c;
}
printf("最大的数是:%d\n", max);
return 0;
}
```
编写一程序,求两个整数的最大公约数
以下是Python语言的程序:
```python
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
a = int(input("请输入第一个整数:"))
b = int(input("请输入第二个整数:"))
result = gcd(a, b)
print("最大公约数为:", result)
```
运行结果示例:
```
请输入第一个整数:24
请输入第二个整数:36
最大公约数为: 12
```
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.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)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)