题解 | #特殊排序#
特殊排序
https://www.nowcoder.com/practice/57f0f528bff149be9580af66f6292430
//这困难个啥劲。。。 #include <iostream> #include <cstdio> #include <algorithm> using namespace std; int main(){ int n; int arr[1000]; while (scanf("%d",&n) != EOF){ for (int i = 0; i < n; ++i) { scanf("%d",&arr[i]); } sort(arr,arr + n); printf("%d\n",arr[n - 1]); if (n == 1){ printf("-1\n"); } else{ for (int i = 0; i < n - 1; ++i) { printf("%d ",arr[i]); } } } }