-
-
Save mariiaKolokolova/ada5876c3bbe78b69307bad9e354cfbb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package maricka.kolokolova; | |
import java.util.Arrays; | |
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
Scanner sc = new Scanner(System.in); | |
System.out.println("Input length of array:"); | |
int size = sc.nextInt(); | |
int[] array = new int[size]; | |
for (int i = 0; i < size; i++) { | |
System.out.println("Input ["+ i + "] element of array:"); | |
array[i] = sc.nextInt(); | |
} | |
System.out.println("Your array is : " + Arrays.toString(array)); | |
System.out.println("Max element in your array is " + findMax(array)); | |
sc.close(); | |
} | |
static int findMax(int[] array) { | |
int min = array[0]; | |
for (int i : array) { | |
if (i > min) { | |
min = i; | |
} | |
} | |
return min; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment