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 CSLight
- {
- class Program
- {
- static void Main(string[] args)
- {
- int arraySize;
- Console.WriteLine("Введите размер массива: ");
- arraySize = Convert.ToInt32(Console.ReadLine());
- int[] array = new int[arraySize];
- Random rand = new Random();
- for (int x = 0; x < arraySize; x++)
- {
- array[x] = rand.Next(0, 100);
- }
- Console.WriteLine("\nИсходный массив: ");
- for (int x = 0; x < arraySize; x++)
- {
- Console.Write(array[x] + " ");
- }
- Console.WriteLine("\n\nЛокальные максимумы: ");
- if (array[0] >= array[1])
- {
- Console.Write(array[0] + " ");
- }
- for (int x = 1; x < arraySize - 1; x++)
- {
- if (array[x] >= array[x-1] && array[x] >= array[x+1])
- {
- Console.Write(array[x] + " ");
- }
- }
- if (array[arraySize-1] >= array[arraySize-2])
- {
- Console.Write(array[arraySize - 1] + " ");
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement