将三个数从

将三个数按从小到大输出
#define _CRT_SECURE_NO_WARNINGS //宏定义
#include <stdio.h>
#include <windows.h>
int main()
{
int a ,b,c,t; //定义四个整型变量,t为临时变量
printf(“输入三个数字”);//任意输入三个整数
scanf("%d%d%d", &a, &b, &c);
if (a < b)
{
t= a;
a = b;
b = t; //如果a<b,a和b借用t交换位置,
}

if (a>c)
{
	t= a;
	a = c;
	c = t;                                //如果a>c,a和c交换位置 
}
if (b > c)
{
	t = b;
	b = c;
	c = t;                               //如果b>c,b和c交换位置
}
printf("%d%d%d", a,b,c);    //打印a,b,c,此时a,b,c已经是从小到大的序列
	system("pause");
return 0;

}

猜你喜欢

转载自blog.csdn.net/weixin_43224539/article/details/82832875