Advertisement
DMG

Serija (z1)

DMG
Apr 16th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. main()
  4. {
  5.       int m, n, a[100][100];
  6.       int serija = -1, br = -1;
  7.       int s = 1;
  8.       int t = 1;
  9.      
  10.       cin >> m >> n;
  11.      
  12.       for (int i=0; i<m; i++)
  13.       for (int j=0; j<n; j++)
  14.           cin >> a[i][j];
  15.      
  16.       for (int i=0; i<m; i++)
  17.       {
  18.           s = 1;
  19.           for (int j=1; j<n; j++)
  20.               if (a[i][j] == a[i][j-1])
  21.                  s = s + 1;
  22.               else
  23.                   if (s>t)
  24.                   {
  25.                           serija = i;
  26.                           t = s;
  27.                           s = 1;
  28.                           br = a[i][j-1];
  29.                   }
  30.                  
  31.           if (s>t)
  32.                   {
  33.                           serija = i;
  34.                           t = s;
  35.                           s = 1;
  36.                           br = a[i][n-1];
  37.                   }
  38.       }
  39.              
  40.       if (serija!=-1)
  41.          cout << serija << " " << br << endl;
  42.       else
  43.          cout << "NULL" << endl;    
  44.  
  45.       system ("PAUSE");
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement