Aleks_Tor

Find Maximum Value [first one]

May 6th, 2021
51
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int times = scanner.nextInt();
  7.         while (times-->0) {
  8.             int[] nums = new int[times+1];
  9.             for (int i = 0; i <times+1; i++) {
  10.                 nums[i] = scanner.nextInt();
  11.             }
  12.             int maximum = nums[0];
  13.             for (int i = 0; i < nums.length; i++){
  14.                 if (nums[i]>maximum){
  15.                     maximum = nums[i];
  16.                 }
  17.             }
  18.              System.out.println(maximum);
  19.         }
  20.     }
  21.     }
RAW Paste Data