Advertisement
Guest User

Untitled

a guest
May 27th, 2016
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 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 Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int[] numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  12. int l = numbers.Length;
  13.  
  14. MaxIncSequence(numbers, l);
  15. }
  16.  
  17. static void MaxIncSequence(int[] numbers, int l)
  18. {
  19. int cntCurrSeq = 0;
  20. int startCurrSeq = 0;
  21. int cntMaxSeq = 0;
  22. int startMaxSeq = 0;
  23.  
  24. for (int i = 1; i < l; i++)
  25. {
  26. if (numbers[i] - numbers[i - 1] >= 1)
  27. {
  28. cntCurrSeq++;
  29. startCurrSeq = i - cntCurrSeq;
  30.  
  31. if (cntCurrSeq > cntMaxSeq)
  32. {
  33. cntMaxSeq = cntCurrSeq;
  34. startMaxSeq = startCurrSeq;
  35. }
  36. }
  37. else
  38. {
  39. cntCurrSeq = 0;
  40. }
  41. }
  42. for (int iWrite = startMaxSeq; iWrite <= (startMaxSeq + cntMaxSeq); iWrite++)
  43. {
  44. Console.Write(numbers[iWrite] + " ");
  45. }
  46. Console.WriteLine();
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement