求助只有10分
查看原帖
求助只有10分
945742
hexuchen楼主2023/6/17 22:24

只有10分还过不了案例

#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m,map[101][101],sum,map2[101][101];
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>map[i][j];
			map2[i][j]=map[i][j];
		}
	}
	for(int i=1;i<m-2;i++){
		for(int j=1;j<n-1;j++){
			sum=map[i-1][j]+map[i+1][j]+map[i][j+1]+map[i][j-1]+map[i][j];
			map2[i][j]=round(sum/5.0);
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cout<<map2[i][j]<<' ';
		}
		cout<<endl;
	}
	return 0;
}
2023/6/17 22:24
加载中...