Advertisement
aggressiveviking

08.IncreasingElements

Mar 5th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _08.IncreasingElements
  4. {
  5.     class IncreasingElements
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.  
  11.             int countCurrentLongest = 0;
  12.             int countLongest = 0;
  13.             int aPrev = 0;
  14.             int a = 0;
  15.  
  16.             for (int i = 0; i < n; i++)
  17.             {
  18.                 a = int.Parse(Console.ReadLine());
  19.  
  20.                 if (a > aPrev)
  21.                 {
  22.                     countCurrentLongest++;
  23.                 }
  24.                 else
  25.                 {
  26.                     countCurrentLongest = 1;
  27.                 }
  28.  
  29.                 if (countCurrentLongest > countLongest)
  30.                 {
  31.                     countLongest = countCurrentLongest;
  32.                 }
  33.  
  34.                 aPrev = a;
  35.             }
  36.  
  37.             Console.WriteLine(countLongest);
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement