题解 | #特殊排序#

特殊排序

https://www.nowcoder.com/practice/57f0f528bff149be9580af66f6292430?tpId=40&tqId=21543&tPage=1&rp=1&ru=/ta/kaoyan&qru=/ta/kaoyan/question-ranking

#include <iostream>
#include<algorithm>
using namespace std;
const int MAX = 1000 + 10;
int arr[MAX]; 

int main() {
    int n;
    while(cin >> n){
        for(int i = 0;i < n;i++){
            cin >> arr[i];
        }
        sort(arr,arr + n);
        cout << arr[n - 1] << endl;
          if(n == 1){
                cout << -1;
            }else{
                for(int i = 0;i < n -1;i++){
        
                    cout << arr[i] << ' ';
            
                }
            }
    
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

11-03 14:57
西北大学 营销
Belltrix:其实就是每根转动一定的角度
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务