c语言中任意输入三个数,比较这三个数的大小,并由小到大输出

#include<stdio.h>
void main()
{
    
    
	int a,b,c,temp;
	printf("请任意输入三个数:\n");
	scanf("%d%d%d",&a,&b,&c);
	if(a>b)
	{
    
    
		temp=a;
		a=b;
		b=temp;
	}
	if(a>c)
	{
    
    
		temp=a;
		a=c;
		c=temp;
	}
	if(b>c)
	{
    
    
		temp=b;
		b=c;
		c=temp;
	}
	
	printf("排序后的三个数为:%d %d %d\n",a,b,c);
}

例如
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/m0_53521757/article/details/111311381