可以通过例子,但是测试全红WA 求解
查看原帖
可以通过例子,但是测试全红WA 求解
919054
nanfengguojing楼主2023/2/28 16:05
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	double a[n][m],b[n][m];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>a[i][j];
			b[i][j]=a[i][j];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(i>0&&i<n-1&&j>0&&j<m-1){
				b[i][j]=(a[i][j]+a[i+1][j]+a[i-1][j]+a[i][j+1]+a[i][j-1])/5.0+0.5;
			}
			cout<<fixed<<setprecision(0)<<b[i][j]<<" ";
		}
		cout<<endl;
	}
	return 0;
}
```
2023/2/28 16:05
加载中...