Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Task22
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random random = new Random();
- string emptyLine = " ";
- string transferString = "\n";
- string outputMaxValue = "Максимальное локальное значение: ";
- string outputIndexMaxValue = " с индексом - ";
- int minValue = 0;
- int maxValue = 10;
- int transleteForComputer = 1;
- int valueForArray = 30;
- int[] array = new int[valueForArray];
- for (int i = minValue; i < array.Length; i++)
- {
- array[i] = random.Next(minValue, (maxValue + transleteForComputer));
- Console.Write(array[i] + emptyLine);
- }
- Console.WriteLine(emptyLine);
- if (array[minValue] > array[minValue + transleteForComputer])
- {
- Console.WriteLine(transferString + outputMaxValue + array[minValue] + outputIndexMaxValue + (minValue + transleteForComputer));
- }
- for (int i = minValue; i < array.Length - transleteForComputer; i++)
- {
- if (i != minValue && array[i] > array[i + transleteForComputer] && array[i] > array[i - transleteForComputer])
- {
- Console.WriteLine(transferString + outputMaxValue + array[i] + outputIndexMaxValue + (i + transleteForComputer));
- }
- }
- if (array[valueForArray-transleteForComputer] > array[valueForArray - transleteForComputer - transleteForComputer])
- {
- Console.WriteLine(transferString + outputMaxValue + array[valueForArray - transleteForComputer] + outputIndexMaxValue + (valueForArray));
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment