Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace ConsoleApp6
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int[] numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  11. int counter = 1;
  12. int counterMax = 0;
  13. int position = 0;
  14. // 4 5 1 2 3 4 5
  15. for (int i = 0; i < numbers.Length - 1; i++)
  16. {
  17. if (numbers[i] < numbers[i + 1])
  18. {
  19. counter++;
  20. if (counter > counterMax)
  21. {
  22. counterMax = counter;
  23. position = i + 1;
  24. }
  25. }
  26. else
  27. {
  28. counter = 1;
  29. }
  30. }
  31. int[] result = new int[counterMax];
  32. for (int i = 0; i < result.Length; i++)
  33. {
  34. result[i] = numbers[position - counterMax+1 + i];
  35. }
  36. Console.WriteLine(string.Join(' ',result));
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement