Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define nmax 100
- using namespace std;
- int v[1000001]={};
- int main()
- {
- int n,m,a[nmax+1][nmax+1],c[4*nmax+2],val,maxx=-1;
- cin>>n>>m;
- for(int i=1;i<=n;i++)
- {
- for(int j=1;j<=m;j++)
- {
- cin>>a[i][j];
- if(a[i][j]>maxx)
- {
- maxx=a[i][j];
- }
- }
- }
- ///prima linie
- for(int j=1;j<m;j++)
- {
- val=a[1][j];
- v[val]++;
- }
- ///ulrima linie
- for(int j=2;j<=m;j++)
- {
- val=a[n][j];
- v[val]++;
- }
- ///prima coloana
- for(int i=2;i<=n;i++)
- {
- val=a[i][1];
- v[val]++;
- }
- ///ultima coloana
- for(int i=1;i<n;i++)
- {
- val=a[i][m];
- v[val]++;
- }
- ///afisare
- for(int p=1;p<=maxx;p++)
- {
- if(v[p]>=1)
- {
- cout<<p<<" ";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement