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 Lesson3
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random rnd = new Random();
- int num1, num2, num3;
- int[] ar = new int[30];
- Console.WriteLine("Исходный массив: ");
- for (int j = 0; j < ar.Length; j++)
- {
- ar[j] = rnd.Next(10,30);
- Console.Write(ar[j]+ " ");
- }
- Console.WriteLine();
- Console.WriteLine("Локальные максимумы: ");
- if (ar[0]>ar[1])
- Console.Write(ar[0] + " ");
- for (int j = 0; j < ar.Length-2; j++)
- {
- num1 = ar[j];
- num2 = ar[j + 1];
- num3 = ar[j + 2];
- if (ar[j + 1] > ar[j] && ar[j + 1] > ar[j + 2])
- Console.Write(ar[j + 1]+" ");
- }
- if (ar[29] > ar[28])
- Console.Write(ar[29] + " ");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement