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;
}
永远年轻 永远热泪盈眶!

浙公网安备 33010602011771号