Advertisement
Guest User

Untitled

a guest
Oct 16th, 2016
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _07.Max_Sequence_of_Increasing_Elements
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  14. var current = 1;
  15. var longest = 0;
  16. var startCurrent = input[0];
  17. var startMax = 0;
  18. for (int i = 0; i < input.Length - 1; i++)
  19. {
  20. if (input[i] < input[i + 1]) current++;
  21. else
  22. {
  23. startCurrent = input[i + 1];
  24. current = 1;
  25. }
  26. if (current > longest)
  27. {
  28. startMax = startCurrent;
  29. longest = current;
  30. }
  31. }
  32. int[] output = new int[longest];
  33. for (int i = 0; i < longest; i++)
  34. {
  35. output[i] = startMax + i;
  36. }
  37. Console.WriteLine(String.Join(" ",output));
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement