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<<'\n';
    return 0;
}

  

posted @ 2020-02-02 22:32  留幸愉  阅读(171)  评论(0编辑  收藏  举报