HUST-特殊排序

网友投稿 952 2022-08-25

HUST-特殊排序

HUST-特殊排序

题目链接

​​3 4 2

输出

复制

41 2 3

题解:

#include #include using namespace std;bool cmp(int a, int b){ return a < b;}int main(){ int n; while(cin >> n){ int buf[1000]; if(n == 1){ cin >> buf[0]; cout << buf[0] << endl << "-1" << endl; } else{ for(int i = 0; i < n; i++){ cin >> buf[i]; } sort(buf, buf + n, cmp); cout << buf[n - 1] << endl; for(int i = 0; i < n - 2; i++){ cout << buf[i] << " "; } cout << buf[n - 2] << endl; } } return 0;}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:人人都要学编程?编程到底有没有前途?(编程好学吗)
下一篇:LeetCode-153. Find Minimum in Rotated Sorted Array&154. Find Minimum in Rotated Sorted Array II
相关文章

 发表评论

暂时没有评论,来抢沙发吧~