Advertisement
simonradev

IncreasingSequence

Jun 1st, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 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 _08.MetricConverter
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double countOfInputs = double.Parse(Console.ReadLine());
  14.  
  15.             int previousNumber = 0;
  16.             int currentNumber = 0;
  17.  
  18.             int countOfCurrentIncreasingSequence = 1;
  19.             int countOfBestIncreasingSequence = 0;
  20.  
  21.             for (int currentInput = 0; currentInput < countOfInputs; currentInput++)
  22.             {
  23.                 previousNumber = currentNumber;
  24.  
  25.                 currentNumber = int.Parse(Console.ReadLine());
  26.  
  27.                 if (currentInput == 0)
  28.                 {
  29.                     countOfBestIncreasingSequence = 1;
  30.                     continue;
  31.                 }
  32.  
  33.                 if (currentNumber > previousNumber)
  34.                 {
  35.                     countOfCurrentIncreasingSequence++;
  36.                 }
  37.                 else
  38.                 {
  39.                     countOfCurrentIncreasingSequence = 1;
  40.                 }
  41.  
  42.                 if (countOfCurrentIncreasingSequence > countOfBestIncreasingSequence)
  43.                 {
  44.                     countOfBestIncreasingSequence = countOfCurrentIncreasingSequence;
  45.                 }
  46.             }
  47.            
  48.             Console.WriteLine(countOfBestIncreasingSequence);
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement