|
|
вернуться в форумWrong Answer in test 4. What is wrong? Please help 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); } } |
|
|