Advertisement
Guest User

MinMaxElement

a guest
Apr 9th, 2020
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. package com.company;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.  
  8.  
  9.  
  10.  
  11.         int[] numArray = {5, 20, 1, 2, 44, 55, 77, 88, 12, 57};
  12.  
  13.  
  14.  
  15.  
  16.     }
  17.  
  18.     int minElement;
  19.     int maxElement;
  20.  
  21.     public static int findMinMax(int[] numArray) {
  22.         for(int i=0; i<numArray.length; i++) {
  23.             for(int j=1; j<numArray.length; j++) {
  24.                 if(numArray[i] > numArray[j]) {
  25.                     maxElement = numArray[i];
  26.                 } else if(numArray[i] < numArray[j]) {
  27.                     minElement = numArray[j];
  28.                 }
  29.             }
  30.         }
  31.     }
  32.  
  33.  
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement