Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n, m;
- cin >> n >> m;
- int mat[n][m];
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- cin >> mat[i][j];
- }
- }
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- int najmal = 2000000000;
- if(i - 1 >= 0) { // goren sosed
- najmal = min(najmal, mat[i - 1][j]);
- }
- if(i + 1 < n) { // dolen sosed
- najmal = min(najmal, mat[i + 1][j]);
- }
- if(j - 1 >= 0) { // lev sosed
- najmal = min(najmal, mat[i][j - 1]);
- }
- if(j + 1 < m) { // desen sosed
- najmal = min(najmal, mat[i][j + 1]);
- }
- if(mat[i][j] < najmal) {
- cout << mat[i][j] << " ";
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement