Advertisement
Guest User

Increasing Sequence

a guest
Mar 22nd, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.    
  5.     int n, n_old=0, counter = 0, max = 0;
  6.    
  7.     do  {
  8.        
  9.         scanf(" %d", &n);      
  10.         if( n > n_old){
  11.             ++counter;
  12.         } else{
  13.             if (max <= counter){ // If the max is smaller than the new sequence
  14.                 max = counter ; // Changes the new max to the counter
  15.                 counter = 1; // Updates the counter
  16.                 }
  17.         }
  18.        
  19.         n_old = n; // Updates the old number for the next loop
  20.  
  21.     }  while( n != 0 );
  22.    
  23.     printf("%d\n", max);
  24.    
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement