将输入的三个数进行按照从小到大排列
#include<stdio.h>void main()
{
int a,b,c,bigger;
printf("请输入三个数字:");
scanf("%d %d %d",&a,&b,&c);
if (a>b)
{
if (a>c)
{
if(b>c)
{}
else
{
bigger=c;
c=b;
b=bigger;
}
}
else
{
bigger=c;
c=a;
a=bigger;
}
printf("从小到大顺序为:%d<%d<%d\n",c,b,a);
}
else//a<b
{
bigger=b;
b=a;
a=bigger;
if (a>c)
{
if(b>c)
{}
else
{
bigger=c;
c=b;
b=bigger;
}
}
else
{
bigger=c;
c=a;
a=bigger;
}
printf("从小到大顺序为:%d<%d<%d\n",c,b,a);
}
}
页:
[1]