Advertisement
Guest User

3.5

a guest
May 19th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Lesson3
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Random rnd = new Random();
  14.             int num1, num2, num3;
  15.             int[] ar = new int[30];
  16.            
  17.             Console.WriteLine("Исходный массив: ");
  18.  
  19.                 for (int j = 0; j < ar.Length; j++)
  20.                 {
  21.                     ar[j] = rnd.Next(10,30);
  22.                     Console.Write(ar[j]+ " ");
  23.                 }
  24.                 Console.WriteLine();
  25.             Console.WriteLine("Локальные максимумы: ");
  26.             if (ar[0]>ar[1])
  27.                 Console.Write(ar[0] + " ");
  28.             for (int j = 0; j < ar.Length-2; j++)
  29.             {
  30.                 num1 = ar[j];
  31.                 num2 = ar[j + 1];
  32.                 num3 = ar[j + 2];
  33.                 if (ar[j + 1] > ar[j] && ar[j + 1] > ar[j + 2])
  34.                     Console.Write(ar[j + 1]+" ");
  35.             }
  36.             if (ar[29] > ar[28])
  37.                 Console.Write(ar[29] + " ");
  38.            
  39.             Console.ReadKey();
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement