Advertisement
rotti321

MChenar

Mar 14th, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. ///MChenar
  2. #include <iostream>
  3. int v[1000001];
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int a[101][101]={},m,n,x,k=0;
  9.     cin>>n>>m;
  10.     for(int i=1;i<=n;i++){
  11.         for(int j=1;j<=m;j++){
  12.             cin>>a[i][j];
  13.         }
  14.     }
  15.     for(int i=1;i<=n;i++)///parcurgem prima coloana si ultima coloana
  16.         {
  17.             x=a[i][1];///element din prima coloana
  18.             v[x]++;
  19.             x=a[i][m];///el din ultima coloana
  20.             v[x]++;
  21.         }
  22.     for(int j=1;j<=m;j++)
  23.     {
  24.         x=a[1][j];///element de pe prima linie
  25.         v[x]++;
  26.         x=a[n][j];///element de pe ultima linie
  27.         v[x]++;
  28.     }
  29.  
  30.     for(int i=1;i<=1000000;i++)
  31.     {
  32.         if(v[i]>0)
  33.         {
  34.             cout<<i<<" ";
  35.         }
  36.     }
  37.  
  38.  
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement