daily pastebin goal
91%
SHARE
TWEET

Idem u mlinar kupit pizzu

a guest Mar 13th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2.  
  3. void init_matrix(int a[12][12], int n, int m){
  4.     unsigned char i, j;
  5.  
  6.     for(i = 1; i <= n; ++i){
  7.         for(j = 1; j <= m; ++j){
  8.             scanf("%d", &a[i][j]);
  9.         }
  10.     }
  11.     for(i = 0; i <= n + 1; ++i){
  12.         a[i][0] = 100;
  13.         a[i][m + 1] = 100;
  14.     }
  15.     for(i = 0; i <= m + 1; ++i){
  16.         a[0][i] = 100;
  17.         a[n + 1][i] = 100;
  18.     }
  19. }
  20.  
  21. void count_minimums(int a[12][12], int n, int m){
  22.     unsigned char i, j;
  23.     int count = 0, global_min = a[1][1];
  24.  
  25.     for(i = 1; i <= n; ++i){
  26.         for(j = 1; j <= m; ++j){
  27.             if(a[i + 1][j] > a[i][j] && a[i - 1][j] > a[i][j] && a[i][j + 1] > a[i][j] && a[i][j - 1] > a[i][j]){
  28.                 if(a[i + 1][j + 1] > a[i][j] &&a[i + 1][j - 1] > a[i][j] &&a[i - 1][j + 1] > a[i][j] &&a[i - 1][j - 1] > a[i][j]){
  29.                     ++count;
  30.                     if(a[i][j] < global_min) global_min = a[i][j];
  31.                 }
  32.             }
  33.         }
  34.     }
  35.     printf("%d\n%d", global_min, count);
  36. }
  37.  
  38. int main(){
  39.     int a[12][12];
  40.     int n, m;
  41.     scanf("%d %d", &n, &m);
  42.  
  43.     init_matrix(a, n, m);
  44.     count_minimums(a, n, m);
  45.  
  46.     return 0;
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top