7-2 比较大小

 题解:用 sort函数,位于 <algorithm>中。

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[5];
int main()
{
    for(int i = 0; i < 3; i++) cin>>a[i];
    sort(a,a+3);
    for(int i = 0; i < 3; i++)
    {
        if(i == 0) cout<<a[i];
        else cout<<"->"<<a[i];
    }
    cout<<'
';
    return 0;
}

  

原文地址:https://www.cnblogs.com/Edviv/p/12254092.html