实现输入3个整数并按从小到大的顺序输出
#include<stdio.h>int main(){int a, b, c;printf("请输入三个整数:");scanf("%d%d%d", &a, &b, &c);//输入三个整数if (a < b) //b小于a时,a值不变;b大于a时,b值赋给a,a值赋给b{int ret = a;a = b;b = ret;}if (a < c){i
·
#include<stdio.h>
int main()
{
int a, b, c;
printf("请输入三个整数:");
scanf("%d%d%d", &a, &b, &c);//输入三个整数
if (a < b) //b小于a时,a值不变;b大于a时,b值赋给a,a值赋给b
{
int ret = a;
a = b;
b = ret;
}
if (a < c)
{
int ret = a;
a = c;
c = ret;
}
if (b < c)
{
int ret = b;
b = c;
c = ret;
}
printf("从大到小排序为:%d %d %d", a, b, c);//将三个整数从大到小排序
return 0;
}
更多推荐
已为社区贡献3条内容
所有评论(0)