Advertisement
medon3

Untitled

Sep 20th, 2022
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Smallergreaterorequal_Variant2 {
  4. public static void main(String[] args) {
  5. Scanner sc = new Scanner(System.in);
  6.  
  7. //This solution works with both negative and positive numbers
  8.  
  9. int n = Integer.parseInt(sc.nextLine());
  10. int[] arr = new int[n];
  11.  
  12.  
  13. for (int i = 0; i < n; i++) {
  14. arr[i] = Integer.parseInt(sc.nextLine());
  15.  
  16. }
  17.  
  18.  
  19. for (int i = 0; i < n; i++) {
  20. System.out.print(arr[i]);
  21.  
  22. if(i==n-1) {
  23. continue;
  24.  
  25. }
  26.  
  27. if (arr [i] > arr[i + 1]) {
  28. System.out.print(" > ");
  29.  
  30. } else if (arr[i] < arr[i + 1]) {
  31. System.out.print(" < ");
  32. } else {
  33. System.out.print(" = ");
  34. }
  35.  
  36.  
  37.  
  38. }
  39.  
  40. }
  41. }
  42.  
  43.  
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement