Advertisement
Guest User

Untitled

a guest
Sep 18th, 2015
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 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. class Longest
  8. {
  9. static void Main()
  10. {
  11. int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  12. List<int> ls = new List<int>();
  13.  
  14. int counter=1;
  15. ls.Add(input[0]);
  16.  
  17. Console.Write(input[0] + " ");
  18. for(int i =1;i<input.Length;i++)
  19. {
  20. if(input[i]>input[i-1])
  21. {
  22. counter++;
  23. Console.Write(input[i]+" ");
  24.  
  25. }
  26. else
  27. {
  28. if (counter > ls.Count)
  29. {
  30. ls.Clear();
  31. for (int j = i - counter; j < i; j++)
  32. {
  33. ls.Add(input[j]);
  34. }
  35. }
  36. counter = 1;
  37. Console.WriteLine();
  38. Console.Write(input[i] + " ");
  39. }
  40. }
  41. Console.WriteLine();
  42. Console.WriteLine("Longest: "+string.Join(" ", ls));
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement