Mancolo

Нерешенная задача

Apr 17th, 2021
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. package com.company;
  2. import java.util.*;
  3. public class Solution {
  4.  
  5. public static void main(String[] args) {
  6. Scanner in = new Scanner(System.in);
  7. int a, i, j, b;
  8. int[] x;
  9. int[] y;
  10. a = in.nextInt();
  11. x = new int[a];
  12. y = new int[a];
  13. for (i = 0; i < a; i++) {
  14. x[i] = in.nextInt();
  15. y[i] = in.nextInt();
  16. }
  17. for (i = 0; i < a - 1; i++)
  18. for (j = i + 1; j < a; j++)
  19. if (y[i] < y[j]) {
  20. b = y[i];
  21. y[i] = y[j];
  22. y[j] = b;
  23. b = x[i];
  24. x[i] = x[j];
  25. x[j] = b;
  26. }
  27. for (i = 0; i < a; i++)
  28. System.out.println(x[i] + " " + y[i]);
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment