public static void main(String[] args) throws Exception {
int[] array = initializeArray();
int max = max(array);
System.out.println(max);
}
public static int[] initializeArray() throws IOException {
Scanner g =new Scanner(System.in);
int [] n = new int[20];
int c = 0;
for (;c<n.length;c++){
n[c]= g.nextInt();
}// ΡΠΎΠ·Π΄Π°ΠΉ ΠΈ Π·Π°ΠΏΠΎΠ»Π½ΠΈ ΠΌΠ°ΡΡΠΈΠ²
return n;
}
public static int max(int[] array){
int j = Integer.MIN_VALUE;
int y = 0;
for (int i = 0; i< array.length - 1; i++) {
y = Math.max(array[i],array[i+1]);
}return y;
}
}
package com.javarush.task.task07.task0701;
import java.io.IOException;
import java.util.Scanner;
/*
ΠΠ°ΡΡΠΈΠ²Π½ΡΠΉ ΠΌΠ°ΠΊΡΠΈΠΌΡΠΌ
*/
public class Solution {
public static void main(String[] args) throws Exception {
int[] array = initializeArray();
int max = max(array);
System.out.println(max);
}
public static int[] initializeArray() throws IOException {
Scanner g =new Scanner(System.in);
int [] n = new int[20];
int c = 0;
for (;c<n.length;c++){
n[c]= g.nextInt();
}// ΡΠΎΠ·Π΄Π°ΠΉ ΠΈ Π·Π°ΠΏΠΎΠ»Π½ΠΈ ΠΌΠ°ΡΡΠΈΠ²
return n;
}
public static int max(int[] array){
int j = Integer.MIN_VALUE;
int y = 0;
for (int i = 0; i< array.length - 1; i++) {
y = Math.max(array[i],array[i+1]);
}return y;
}
}