SlavCodes

Untitled

Apr 13th, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6.  
  7. Scanner reader = new Scanner(System.in);
  8.  
  9. int numberOfInputs = Integer.parseInt(reader.nextLine());
  10.  
  11. StringBuffer stringBuffer = new StringBuffer();
  12.  
  13.  
  14. //checks if there are inputs
  15. if(numberOfInputs == 0){
  16. return;
  17. }
  18.  
  19. int previousNum = Integer.parseInt(reader.nextLine());
  20. stringBuffer.append(previousNum);
  21.  
  22.  
  23. for (int i = 0; i <numberOfInputs-1 ; i++) {
  24.  
  25. int currentNum = Integer.parseInt(reader.nextLine());
  26.  
  27. if(currentNum > previousNum){
  28. stringBuffer.append("<").append(currentNum);
  29. } else if (currentNum < previousNum){
  30. stringBuffer.append(">").append(currentNum);
  31. } else {
  32. stringBuffer.append("=").append(currentNum);
  33. }
  34.  
  35.  
  36. previousNum = currentNum;
  37. }
  38.  
  39.  
  40. System.out.println(stringBuffer);
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment