Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Lesson8
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] a = new int[30];
- Random rand = new Random();
- Console.WriteLine("Исходный масив");
- for (int i = 0; i < a.GetLength(0); i++)
- {
- a[i] = rand.Next(0,100);
- Console.Write(a[i] + " ");
- }
- Console.WriteLine("\nДокальные максимумы");
- for (int i = 0; i < a.GetLength(0); i++)
- {
- if (i == 0)
- {
- if (a[i] > a[i + 1])
- Console.Write(a[i] + " ");
- }
- else if(i== a.GetLength(0) - 1)
- {
- if (a[i] > a[i - 1])
- Console.Write(a[i] + " ");
- }
- else
- {
- if (a[i] > a[i + 1] && a[i] > a[i - 1])
- Console.Write(a[i] + " ");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement