sivancheva

Max Sequence of Increasing Elements

Aug 16th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. /*
  2. * Created by SharpDevelop.
  3. * User: savina.ivancheva
  4. * Date: 14.08.2017
  5. * Time: 10:34
  6. *
  7. * To change this template use Tools | Options | Coding | Edit Standard Headers.
  8. */
  9. using System;
  10. using System.Linq;
  11.  
  12. namespace MaxSequenceOfIncreasingElements
  13. {
  14. class Program
  15. {
  16. public static void Main(string[] args)
  17. {
  18. var array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  19.  
  20. int startCurrent = array[0];
  21. int counterCurrent = 1;
  22.  
  23. int start = startCurrent;
  24. int counter = counterCurrent;
  25.  
  26.  
  27. for (int i = 0; i < array.Length-1; i++)
  28. {
  29.  
  30. if (array[i] < array[i+1])
  31. {
  32. counterCurrent++;
  33.  
  34. if (counterCurrent > counter)
  35. {
  36. counter = counterCurrent;
  37. startCurrent = array[i];
  38. }
  39. }
  40. else
  41. {
  42. counterCurrent = 1;
  43.  
  44. }
  45.  
  46.  
  47. }
  48.  
  49.  
  50. for (int j = 0; j < counter; j++)
  51. {
  52. Console.Write("{0} ", start+j);
  53. }
  54. Console.WriteLine();
  55.  
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment