数字排序 编程

来源:百度知道 编辑:UC知道 时间:2024/05/14 16:59:04
Write a program that asks the user to input three numbers, and then outputs
the numbers from the smallest to the largest. For example, if the input is
23 5 15, the output is 5 15 23.

#include<stdio.h>
void main()
{
int a,b,c;
int min;
printf("Please input three numbers:\n");
scanf("%d %d %d",&a,&b,&c);
if(a>b)
{
min=a;a=b;b=min;
}
if(a>c)
{
min=a;a=c;c=min;
}
if(b>c)
{
min=b;b=c;c=min;
}
printf("%d %d %d \n\n",a,b,c);
}