Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MinMaxArray
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] myArray = { 1,2,3,4,5,6,7,8};
- Console.WriteLine("Min {0}", FindMin(myArray));
- Console.WriteLine("Max {0}", FindMax(myArray));
- }
- static int FindMin(int[] a)
- {
- int min = a[0];
- for (int i = 0; i < a.Length; i++)
- {
- if (a[i] < min) min = a[i];
- }
- return min;
- }
- static int FindMax(int[] a)
- {
- int min = a[0];
- for (int i = 0; i < a.Length; i++)
- {
- if (a[i] > min) min = a[i];
- }
- return min;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement