Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Created by SharpDevelop.
- * User: savina.ivancheva
- * Date: 14.08.2017
- * Time: 10:34
- *
- * To change this template use Tools | Options | Coding | Edit Standard Headers.
- */
- using System;
- using System.Linq;
- namespace MaxSequenceOfIncreasingElements
- {
- class Program
- {
- public static void Main(string[] args)
- {
- var array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- int startCurrent = array[0];
- int counterCurrent = 1;
- int start = startCurrent;
- int counter = counterCurrent;
- for (int i = 0; i < array.Length-1; i++)
- {
- if (array[i] < array[i+1])
- {
- counterCurrent++;
- if (counterCurrent > counter)
- {
- counter = counterCurrent;
- startCurrent = array[i];
- }
- }
- else
- {
- counterCurrent = 1;
- }
- }
- for (int j = 0; j < counter; j++)
- {
- Console.Write("{0} ", start+j);
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment