题目3 特殊排序

 

 1 import java.util.Arrays;
 2 import java.util.Scanner;
 3  
 4 public class Main{
 5     public static void main(String[]args){
 6         Scanner in=new Scanner(System.in);
 7         int n=0;
 8         int[]nums=null;
 9         while(in.hasNext()){
10             n=in.nextInt();
11             nums=new int[n];
12             for(int i=0;i<n;i++)
13                 nums[i]=in.nextInt();
14             Arrays.sort(nums);
15             System.out.println(nums[n-1]);
16             if(n==1) System.out.println(-1);
17             else{
18                 for(int i=0;i<n-2;i++)
19                     System.out.print(nums[i]+" ");
20                 System.out.println(nums[n-2]);
21                  
22             }
23         }
24     }
25 }
26 /**************************************************************
27     Problem: 1185
28     User: 0000H
29     Language: Java
30     Result: Accepted
31     Time:980 ms
32     Memory:78572 kb
33 ****************************************************************/

 

posted @ 2015-09-09 10:34  打小孩  阅读(159)  评论(0编辑  收藏  举报