Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string localMax = "";
- Random random = new Random();
- int[] array = new int[30];
- int maxRandomNumber = 10;
- int minRandomNumber = 0;
- int lastIndex = array.Length - 1;
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = random.Next(minRandomNumber, maxRandomNumber + 1);
- Console.Write(array[i] + " ");
- }
- if (array[0] > array[1])
- {
- localMax += array[0] + " ";
- }
- for (int i = 1; i < lastIndex; i++)
- {
- if (array[i] > array[i + 1] && array[i] > array[i - 1])
- {
- localMax += array[i] + " ";
- }
- }
- if (array[lastIndex] > array[lastIndex - 1])
- {
- localMax += "" + array[lastIndex];
- }
- Console.WriteLine($"\n\nЛокальные максимумы: {localMax}");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement