package Algoritmy; import java.io.*; import java.util.ArrayList; public class JadnTest { public static int[][] Sort(int column) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); //int column = Integer.parseInt(reader.readLine()); int mas[][] = new int[column][2]; for (int i = 0; i < column; i++) { mas[i][0] = Integer.parseInt(reader.readLine()); mas[i][1] = Integer.parseInt(reader.readLine()); System.out.println(mas[i][0]); System.out.println(mas[i][1]); } int p1; int p2; for (int j = 0; j < column; j++) { for (int i = 0; i < column; i++) { if (mas[i + 1][2] < mas[i][2]) { p1 = mas[i + 1][1]; p2 = mas[i + 1][2]; mas[i + 1][1] = mas[i][1]; mas[i + 1][2] = mas[i][2]; mas[i][1] = p1; mas[i][2] = p2; } } } return mas; } public static void PointSearch() throws IOException{ int k = 0; int n = 0; ArrayList<Integer> tochka = new ArrayList<Integer>(); for (int i = 0, j = 0; i < column; i++) { if (mas[j][2] >= mas[i + 1][1] & mas[j][2] <= mas[i + 1][2]) { k++; } else { tochka.add(mas[j][2]); n++; j = i = k + 1; } } System.out.println(n); for (int i = 0; i <= n; i++) { System.out.println(tochka.get(i)); } } public static void main(String[] args) throws IOException { JadnTest obj = new JadnTest(); BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); obj.Sort(Integer.parseInt(reader.readLine())); //PointSearch(); } }