Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Smallergreaterorequal_Variant2 {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- //This solution works with both negative and positive numbers
- int n = Integer.parseInt(sc.nextLine());
- int[] arr = new int[n];
- for (int i = 0; i < n; i++) {
- arr[i] = Integer.parseInt(sc.nextLine());
- }
- for (int i = 0; i < n; i++) {
- System.out.print(arr[i]);
- if(i==n-1) {
- continue;
- }
- if (arr [i] > arr[i + 1]) {
- System.out.print(" > ");
- } else if (arr[i] < arr[i + 1]) {
- System.out.print(" < ");
- } else {
- System.out.print(" = ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement