Advertisement
Dido09

MinMax

Oct 15th, 2019
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class NumSeq {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int n = Integer.parseInt(scanner.nextLine());
  8.  
  9. int maxNum = Integer.MIN_VALUE;
  10. int minNum = Integer.MAX_VALUE;
  11. for (int i = 0; i < n ; i++){
  12.  
  13. int num = Integer.parseInt(scanner.nextLine());
  14.  
  15. if (num > maxNum){
  16. maxNum = num;
  17. }
  18. if (num < minNum){
  19. minNum = num;
  20. }
  21. }
  22. System.out.println("Max number: " + maxNum);
  23. System.out.println("Min number: " + minNum);
  24.  
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement