Advertisement
nicuvlad76

Untitled

Jan 28th, 2023
711
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.46 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. #include <algorithm>
  4. #define N 105
  5. using namespace std;
  6. ifstream fin(".in");
  7. ofstream fout(".out");
  8. ///778
  9. int a[N][N],n,m;
  10. int fr[4*N];
  11. int main()
  12. {
  13.   int vmin=10005, vmax=-1;
  14.   int i,j;
  15.   cin>>n>>m;
  16.   for(i=1; i<=n; ++i)
  17.     for( j=1; j<=m; ++j)
  18.       {
  19.           cin>>a[i][j];
  20.       }
  21.    ///crearea unui vector de frecventa manual
  22.    int k=0,x;
  23.    bool gasit;
  24.    ///liniile 1 si n
  25.    for(j=1;j<=m;j++)
  26.    {
  27.       x=a[1][j];///linia 1
  28.       if(k==0) fr[++k]=x;
  29.       else
  30.       {
  31.           gasit=0;
  32.           for(i=1;i<=k && !gasit; ++i)
  33.             if(fr[i]==x)gasit=1;
  34.           if(gasit==0)fr[++k]=x;
  35.       }
  36.       x=a[n][j];///linia n
  37.       if(k==0) fr[++k]=x;
  38.       else
  39.       {
  40.           gasit=0;
  41.           for(i=1;i<=k && !gasit; ++i)
  42.             if(fr[i]==x)gasit=1;
  43.           if(gasit==0)fr[++k]=x;
  44.       }
  45.    }
  46.    ///coloana 1 si m
  47.    for(i=2;i<m;i++)
  48.    {
  49.        x=a[i][1];///coloana 1
  50.       if(k==0) fr[++k]=x;
  51.       else
  52.       {
  53.           gasit=0;
  54.           for(j=1;j<=k && !gasit; ++j)
  55.             if(fr[j]==x)gasit=1;
  56.           if(gasit==0)fr[++k]=x;
  57.       }
  58.       x=a[i][m];///coloana m
  59.       if(k==0) fr[++k]=x;
  60.       else
  61.       {
  62.           gasit=0;
  63.           for(j=1;j<=k && !gasit; ++j)
  64.             if(fr[j]==x)gasit=1;
  65.           if(gasit==0)fr[++k]=x;
  66.       }
  67.    }
  68.  
  69.   sort(fr+1, fr+k+1);
  70.  
  71.   for(i=1;i<=k;i++)
  72.     if(!fr[i])cout<<fr[i]<<" ";
  73.   return 0;
  74. }
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement