SHARE
TWEET

InteviewQuestionForReddit

CryptoJones Jun 15th, 2018 145 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   static void Main(string[] args)
  2.         {
  3.  
  4.             int[] myArray = new int[] {2, 4, 8, 16, 32, 64, 128, 256};
  5.  
  6.             Console.WriteLine(GetMaxAndMin(myArray));
  7.             Console.ReadLine();
  8.         }
  9.  
  10.         static string GetMaxAndMin(int[] array)
  11.         {
  12.  
  13.             int min = array[0];
  14.             int max = array[0];
  15.  
  16.             foreach (int n in array)
  17.             {
  18.                 if (min > n) {
  19.                     min = n;
  20.                 }
  21.  
  22.                 if (max < n)
  23.                 {
  24.                     max = n;
  25.                 }
  26.  
  27.             }
  28.  
  29.             return "Min = " + min + ", Max = " + max + ".";
  30.         }
  31.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top