您的位置:首页 > 其它

输入三个数,然后从大到小输出

2013-03-30 00:29 190 查看
#include <stdio.h>

#include <stdlib.h>

void Descending(int &a,int &b,int &c){

int temp=0;

if(a<b){

temp=a;a=b;b=temp;//促使a>=b

}

if(b<c){

temp=c;c=b;//促使temp>=c

if(a>=temp) b=temp;

else{

b=a;a=temp;//注意,不能写成a=temp;b=a;

}

}

}

int main()

{

int a,b,c;

scanf("%d%d%d",&a,&b,&c);

Descending(a,b,c);

printf("%d %d %d\n",a,b,c);

system("pause");

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐