ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1313. Some Words about Sport

Wrong 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