Advertisement
vov44k

Поиск максимума

Feb 27th, 2022
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner in = new Scanner(System.in);
  7.  
  8.         int n = in.nextInt();
  9.         int[] a = new int[n];
  10.         for (int i = 0; i < n; i++) {
  11.             a[i] = in.nextInt();
  12.         }
  13.         int max = Integer.MIN_VALUE;
  14.         for (int i = 0; i < n; i++) {
  15.             if (a[i] > max)
  16.                 max = a[i];
  17.         }
  18.  
  19.         System.out.print(max);
  20.  
  21.         in.close();
  22.     }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement