Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: 曹北健(37509)
- Result: AC Submission_id: 5310407
- Created at: Sat Apr 01 2023 17:25:55 GMT+0800 (China Standard Time)
- Problem: 6810 Time: 12 Memory: 2152
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
- #include <ctype.h>
- #include <time.h>
- #pragma warning(disable:4996 6031)
- int a[128][128] = { 0 };
- int main(){
- int m, n, i, j, dx, dy;
- scanf("%d%d", &m, &n);
- for(i = 0; i < m; i++){
- for(j = 0; j < n; j++){
- scanf("%d", &(a[i][j]));
- }
- }
- for(i = 0; i < m; i++){
- for(j = 0; j < n; j++){
- int cnt = 0;
- double sum = 0;
- for(dx = -1; dx <= 1; dx++){
- for(dy = -1; dy <= 1; dy++){
- if((i + dx >= 0) && (i + dx < m) && (j + dy >= 0) && (j + dy < n)){
- sum += a[i + dx][j + dy];
- cnt += 1;
- }
- }
- }
- printf("%3d ", (int)round(sum / cnt));
- }
- putchar('\n');
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement