Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- internal class Program
- {
- static void Main(string[] args)
- {
- Random random = new Random();
- int minValueRandomNumber = 1;
- int maxValueRandomNumber = 10;
- int numberOfNumbers = 30;
- int[] numbersInLine = new int[numberOfNumbers];
- int lastNumberInLine = numbersInLine.Length - 1;
- for (int i = 0; i < numberOfNumbers; i++)
- {
- numbersInLine[i] = random.Next(minValueRandomNumber, maxValueRandomNumber);
- Console.Write(numbersInLine[i] + " ");
- }
- Console.WriteLine();
- if (numbersInLine[0] > numbersInLine[1])
- {
- Console.Write(numbersInLine[0] + " ");
- }
- for (int i = 1; i < numbersInLine.Length - 1; i++)
- {
- if (numbersInLine[i] > numbersInLine[i - 1] && numbersInLine[i] > numbersInLine[i + 1])
- {
- Console.Write(numbersInLine[i] + " ");
- i++;
- }
- }
- if (numbersInLine[lastNumberInLine] > numbersInLine[lastNumberInLine - 1])
- {
- Console.Write(numbersInLine[lastNumberInLine]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement