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 Answer in test 4. What is wrong? Please help
Posted by Maksadbek 6 Oct 2014 22:11
import java.util.Scanner;


public class Main {

    public static int[] insertation_sort(int[] toBeSorted){
        for(int i=1; i<toBeSorted.length; i++){
            int x = toBeSorted[i];
            int y = i;
            while( y>0 && (toBeSorted[y-1] > x)){
                toBeSorted[y] = toBeSorted[y -1];
                y -= 1;
            }
            toBeSorted[y] = x;
        }
        return toBeSorted;
    }


    public static void some_words_about_sport() {

        Scanner scanner = new Scanner(System.in);
        int times = Integer.parseInt(scanner.nextLine());
        int[] inputNumbers = new int[times*times];
        int counter=0;
        for (int i = 0; i < times; i++) {
            for(int l =0; l<times; l++){
                int inputs = scanner.nextInt();
                inputNumbers[counter] = inputs;
                counter++;
            }
        }
        inputNumbers = insertation_sort(inputNumbers);

        //print the solution
        for(int x: inputNumbers){
            System.out.print(String.format("%d ", x));
        }
    }

    public static void main(String[] args) {
        some_words_about_sport();
        System.exit(0);
    }
}