1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
static void Main(string[] args) { //www.csharp-console-examples.com int[] numbers = new int[10]; Random rnd = new Random(); int min, max; for (int i = 0; i < numbers.Length; i++) { numbers[i] = rnd.Next(1, 100); Console.WriteLine(numbers[i]); } min = numbers[0]; max = numbers[0]; for (int i = 1; i < numbers.Length; i++) { if (min > numbers[i]) min = numbers[i]; if (max < numbers[i]) max = numbers[i]; } Console.WriteLine("====================================="); Console.WriteLine("The highest number in the array: > > > " + max); Console.WriteLine("The lowest number in the array: > > > " + min); Console.ReadKey(); } |