Advertisement
Huskymeister

Max/Min

Feb 18th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.61 KB | None | 0 0
  1.         public static int getMax(int[] arr)
  2.         {
  3.             int max = arr[0];
  4.             for(int i = 1; i < arr.Length; i++)
  5.             {
  6.                 if(arr[i] > max)
  7.                 {
  8.                     max = arr[i];
  9.                 }
  10.             }
  11.             return max;
  12.         }
  13.  
  14.  
  15.         public static int getMin(int[] arr)
  16.         {
  17.             int min = arr[0];
  18.             for (int i = 1; i < arr.Length; i++)
  19.             {
  20.                 if (arr[i] < max)
  21.                 {
  22.                     min = arr[i];
  23.                 }
  24.             }
  25.             return min;
  26.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement