下面程序对这两个整数按从小到大的顺序输出,请在空白处填空
时间: 2023-03-31 11:01:17 浏览: 66
int a, b;
scanf("%d %d", &a, &b);
if (a > b) {
int temp = a;
a = b;
b = temp;
}
printf("%d %d", a, b);
答案:temp
相关问题
下面程序对这两个整数按从小到大的顺序输出
请给出这个程序的代码。
可以的,这是一个简单的排序程序,代码如下:
#include <stdio.h>
int main()
{
int a, b, temp;
scanf("%d %d", &a, &b);
if (a > b) {
temp = a;
a = b;
b = temp;
}
printf("%d %d\n", a, b);
return ;
}
下面的程序是从键盘输入三个整数 按从小到大的顺序输出。
以下是使用 Python 语言编写的程序,可以实现从键盘输入三个整数,按从小到大的顺序输出:
```python
a = int(input("请输入第一个整数:"))
b = int(input("请输入第二个整数:"))
c = int(input("请输入第三个整数:"))
if a <= b and a <= c:
if b <= c:
print(a, b, c)
else:
print(a, c, b)
elif b <= a and b <= c:
if a <= c:
print(b, a, c)
else:
print(b, c, a)
else:
if a <= b:
print(c, a, b)
else:
print(c, b, a)
```
该程序首先使用 `input()` 函数从键盘输入三个整数,然后使用 if 语句判断三个整数的大小关系,并按照从小到大的顺序输出。