Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- #include <algorithm>
- #define N 105
- using namespace std;
- ifstream fin(".in");
- ofstream fout(".out");
- ///778
- int a[N][N],n,m;
- int fr[4*N];
- int main()
- {
- int vmin=10005, vmax=-1;
- int i,j;
- cin>>n>>m;
- for(i=1; i<=n; ++i)
- for( j=1; j<=m; ++j)
- {
- cin>>a[i][j];
- }
- ///crearea unui vector de frecventa manual
- int k=0,x;
- bool gasit;
- ///liniile 1 si n
- for(j=1;j<=m;j++)
- {
- x=a[1][j];///linia 1
- if(k==0) fr[++k]=x;
- else
- {
- gasit=0;
- for(i=1;i<=k && !gasit; ++i)
- if(fr[i]==x)gasit=1;
- if(gasit==0)fr[++k]=x;
- }
- x=a[n][j];///linia n
- if(k==0) fr[++k]=x;
- else
- {
- gasit=0;
- for(i=1;i<=k && !gasit; ++i)
- if(fr[i]==x)gasit=1;
- if(gasit==0)fr[++k]=x;
- }
- }
- ///coloana 1 si m
- for(i=2;i<m;i++)
- {
- x=a[i][1];///coloana 1
- if(k==0) fr[++k]=x;
- else
- {
- gasit=0;
- for(j=1;j<=k && !gasit; ++j)
- if(fr[j]==x)gasit=1;
- if(gasit==0)fr[++k]=x;
- }
- x=a[i][m];///coloana m
- if(k==0) fr[++k]=x;
- else
- {
- gasit=0;
- for(j=1;j<=k && !gasit; ++j)
- if(fr[j]==x)gasit=1;
- if(gasit==0)fr[++k]=x;
- }
- }
- sort(fr+1, fr+k+1);
- for(i=1;i<=k;i++)
- if(!fr[i])cout<<fr[i]<<" ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement