Advertisement
rotti321

MChenar

Apr 12th, 2018
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #define nmax 100
  3.  
  4. using namespace std;
  5.  
  6. int v[1000001]={};
  7.  
  8. int main()
  9. {
  10.     int n,m,a[nmax+1][nmax+1],c[4*nmax+2],val,maxx=-1;
  11.     cin>>n>>m;
  12.     for(int i=1;i<=n;i++)
  13.     {
  14.         for(int j=1;j<=m;j++)
  15.         {
  16.             cin>>a[i][j];
  17.             if(a[i][j]>maxx)
  18.             {
  19.                 maxx=a[i][j];
  20.             }
  21.         }
  22.     }
  23.     ///prima linie
  24.     for(int j=1;j<m;j++)
  25.     {
  26.         val=a[1][j];
  27.         v[val]++;
  28.     }
  29.     ///ulrima linie
  30.     for(int j=2;j<=m;j++)
  31.     {
  32.         val=a[n][j];
  33.         v[val]++;
  34.     }
  35.     ///prima coloana
  36.     for(int i=2;i<=n;i++)
  37.     {
  38.         val=a[i][1];
  39.         v[val]++;
  40.     }
  41.     ///ultima coloana
  42.     for(int i=1;i<n;i++)
  43.     {
  44.         val=a[i][m];
  45.         v[val]++;
  46.     }
  47.     ///afisare
  48.     for(int p=1;p<=maxx;p++)
  49.     {
  50.         if(v[p]>=1)
  51.         {
  52.             cout<<p<<" ";
  53.         }
  54.  
  55.     }
  56.  
  57.  
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement