Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Homework3_3
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Random random = new Random();
- int[] numbers = new int[30];
- int localMaximum = 0;
- int lastIndexArray = numbers.Length - 1;
- int firstIndexArray = 0;
- int minNumber = 1;
- int maxNumber = 100;
- for (int i = 0; i < numbers.Length; i++)
- {
- numbers[i] = random.Next(minNumber, maxNumber + 1);
- Console.WriteLine(numbers[i] + " ");
- }
- Console.WriteLine();
- if (numbers[firstIndexArray] > numbers[firstIndexArray + 1])
- {
- localMaximum = numbers[firstIndexArray];
- Console.Write(localMaximum + " ");
- }
- for (int i = 1; i < lastIndexArray; i++)
- {
- if (numbers[i] > numbers[i - 1] && numbers[i] > numbers[i + 1])
- {
- localMaximum = numbers[i];
- Console.Write(localMaximum + " ");
- }
- }
- if (numbers[lastIndexArray] > numbers[lastIndexArray - 1])
- {
- localMaximum = numbers[lastIndexArray];
- Console.Write(localMaximum + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement