标签:des style http color io os java ar for
6 1 2 3 4 5 6
1 6 3 4 5 2
java的Arrays类居然只有升序排序。。sad
import java.io.*; import java.util.*; import java.math.*; import java.text.*; public class Main { public static void main(String[] args){ Scanner in=new Scanner(System.in); int n; int[] a=new int[200]; int[] b=new int[200]; n=in.nextInt(); int p=0,q=0; for(int i=1;i<=n;i++) if(i%2!=0){ a[p]=in.nextInt(); p++; } else{ b[q]=in.nextInt(); q++; } Arrays.sort(a,0,p);Arrays.sort(b,0,q); p=0;q--; for(int i=1;i<=n;i++) if(i%2!=0){ System.out.print(a[p]+" "); p++; } else{ System.out.print(b[q]+" "); q--; } } }
标签:des style http color io os java ar for
原文地址:http://blog.csdn.net/qq_16255321/article/details/39322419