|
|
back to boardWrong Answe test 4 java Posted by shagi 2 Oct 2014 18:54 I don't understand what's wrong? In my IDEA all works! import java.io.IOException; import java.util.Scanner; public class summa { public static void main(String[] args) throws IOException { Scanner s = new Scanner(System.in); int n = s.nextInt(); int[] mas = new int[n*n]; if(n!= 0) { for (int i = 0; i < n * n; i++) { mas[i]=s.nextInt(); } if(mas.length>1) { qSort(mas, 0, mas.length-1); for (int i = 0; i < mas.length; i++) { System.out.print(mas[i] + " "); } }else System.out.println(mas[0]); }else System.out.println("0 элемнтов"); } public static void qSort(int[] A, int low, int high) { int i = low; int j = high; int x = A[(low+high)/2]; do { while(A[i] < x) ++i; while(A[j] > x) --j; if(i <= j){ int temp = A[i]; A[i] = A[j]; A[j] = temp; i ++ ; j --; } } while(i <= j);
if(low < j) qSort(A, low, j); if(i < high) qSort(A, i, high); } } Edited by author 02.10.2014 20:36 Edited by author 02.10.2014 20:36 |
|
|