Advertisement
radostina92

Задача1

May 12th, 2022
842
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. // алтернативно решение с linq и list
  2.  
  3. int[] inputArray = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();
  4.  
  5. List<int> result = new List<int>();
  6. for (int i = 0; i < inputArray.Length; i++)
  7. {
  8.    
  9.     if(i == 0)
  10.     {
  11.         continue;
  12.     }
  13.     else
  14.     {
  15.         if(inputArray[i - 1] < inputArray[i])
  16.         {
  17.             result.Add(inputArray[i]);
  18.             result.Remove(inputArray[i - 1]);
  19.         }
  20.     }
  21.  
  22. }
  23.  
  24.  
  25. Console.WriteLine(string.Join(" ", result));
  26. Console.WriteLine(result.Count());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement