Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- int[] myArray = new int[] {2, 4, 8, 16, 32, 64, 128, 256};
- Console.WriteLine(GetMaxAndMin(myArray));
- Console.ReadLine();
- }
- static string GetMaxAndMin(int[] array)
- {
- int min = array[0];
- int max = array[0];
- foreach (int n in array)
- {
- if (min > n) {
- min = n;
- }
- if (max < n)
- {
- max = n;
- }
- }
- return "Min = " + min + ", Max = " + max + ".";
- }
- }
Add Comment
Please, Sign In to add comment