输入三个数,将它们按从大到小的顺序打出来,怎么编写更简便些的程序呢?

来源:百度知道 编辑:UC知道 时间:2024/05/23 12:18:56

给个简单的思路~
int a ,b,c;
if(a>b)
{
if(a>c)
{
this.Response.Write(a);
}
if(b>c)
{
this.Response.Write(b,c)
}
else
{
this.Response.Write(c,b)
}
}
if(a>c)
{
this.Response.Write(b,a,c)
}
else
{
if(b>c)
{
this.Response.Write(b,c,a)
}
else
{
this.Response.Write(c,b,a)
}
}

不知道你说的是用哪种语言编写的,我这有个c语言的样本!可以参考下
#include<stdio.h>
void main()
{
int a,b,c,temp;
printf("输入三个数字:");
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);
}