Advertisement
LegoDrifter

Lab 6 - 3

Dec 9th, 2020
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.77 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int longestSubsequence(int a[100][100], int n) {
  4.    
  5.     int i, j, maxCount=0, count=1;
  6.  
  7.     for(i=0; i<n; i++){
  8.        for(j=0; j<n-1; j++){
  9.             if(a[i][j] < a[i][j+1])
  10.                 count++;
  11.             else{
  12.                 if(count > maxCount)
  13.                     maxCount = count;
  14.                 count=1;
  15.             }
  16.        }
  17.         if(count > maxCount)
  18.             maxCount = count;
  19.  
  20.         count=1;
  21.     }
  22.  
  23.     return maxCount;
  24. }
  25.  
  26. int main() {
  27.     int i, j, n;
  28.     int a[100][100];
  29.     scanf("%d", &n);  
  30.  
  31.     for(i = 0; i < n; ++i) {
  32.         for(j = 0; j < n; ++j) {
  33.             scanf("%d", &a[i][j]);
  34.         }
  35.     }
  36.  
  37.     int result = longestSubsequence(a, n);
  38.     printf("%d", result);
  39.  
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement