Advertisement
Dani_info

Teza s2

May 21st, 2018
97
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n; cout<<"n="; cin>>n;
  8.     int v[n][n];
  9.     cout<<"Introdu elementele matricii:"<<endl;
  10.     for (int i=0; i<n; i++){
  11.         for (int j=0; j<n; j++)
  12.             cin>>v[i][j];
  13.     }
  14.  
  15.     cout<<"-----------------"<<endl;
  16.     //in centrul matricii
  17.     for (int i=1; i<n-1; i++){
  18.         for (int j=1; j<n-1; j++){
  19.             if (v[i][j]<v[i][j-1]&&v[i][j]<v[i][j+1]&& v[i][j]<<v[i+1][j]&&v[i][j]<v[i-1][j])
  20.                 cout<<v[i][j]<<" ";
  21.         }
  22.     }
  23.     //pe marginea stg si dr
  24.     for (int i=1; i<n-1; i++){
  25.         if (v[i][0]<v[i-1][0]&&v[i][0]<v[i+1][0] && v[i][0]<v[i][1])
  26.             cout<<v[i][0]<<endl;
  27.         if (v[i][n-1]<v[i-1][n-1]&&v[i][n-1]<v[i+1][n-1] && v[i][n-1]<v[i][n-2])
  28.             cout<<v[i][n-1];
  29.     }
  30.     //pe partea de sus si pe parrtea de jos
  31.     for (int i=1; i<n-1; i++){
  32.         if (v[0][i]<v[0][i-1]&&v[0][i]<v[0][i+1]&& v[0][i]<v[1][i])
  33.             cout<<v[0][i];
  34.         if (v[n-1][i]<v[n-1][i-1]&&v[n-1][i]<v[n-1][i+1]&&v[n-1][i]<v[n-2][i])
  35.             cout<<v[n-1][i];
  36.     }
  37.  
  38.  
  39.     return 0;
  40. }
Advertisement
RAW Paste Data Copied
Advertisement