算法竞赛入门经典

版权声明:转自可爱的安安的博客!qq:1085589289 https://blog.csdn.net/ac1085589289/article/details/86420373

例题1-5 三整数排序

输入3个整数,从小到大排序后输出。

样例输入:

20 7 33

样例输出:

7 20 33

#include<iostream>
using namespace std;
int main()
{
	int a, b, c,t;
	cin>>a>>b>>c;
	if(a>b){ t=a; a=b; b=t;} 
	if(a>c){ t=a; a=c; c=t;}
	if(b>c){ t=b; b=c; c=t;}
	cout<<a<<" "<<b<<" "<<c;
	return 0;
}

猜你喜欢

转载自blog.csdn.net/ac1085589289/article/details/86420373