Advertisement
alexey3017

Untitled

Mar 22nd, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 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. namespace Learn1
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. int[] array = new int[30];
  13. Random rand = new Random();
  14.  
  15. for (int i = 0; i < array.Length; i++)
  16. {
  17. array[i] = rand.Next(0, 100);
  18. Console.Write(array[i] + " ");
  19. }
  20. Console.WriteLine();
  21. for (int i = 0; i < array.Length; i++)
  22. {
  23. if (array[i] == array.Length - 1)
  24. {
  25. if (array[i] > array[i - 1])
  26. {
  27. Console.WriteLine("Локальный максимум " + array[i]);
  28. }
  29. }
  30. else if (array[i] == array[0])
  31. {
  32. if(array[i] > array[i + 1])
  33. {
  34. Console.WriteLine("Локальный максимум " + array[i]);
  35. }
  36. }
  37. else if (array[i] > array[i - 1] && array[i] > array[i + 1])
  38. {
  39. Console.WriteLine("Локальный максимум " + array[i]);
  40. }
  41. }
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement