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