1 条题解
-
1
#include<bits/stdc++.h> using namespace std; int main() { int a,f=0; cin>>a; int e[a][a]; for(int i=0;i<a;i++) for(int j=0;j<a;j++) cin>>e[i][j]; for(int i=0;i<a;i++) { for(int j=0;j<a;j++) { f=0; if(i>=0&&i<a&&j>=0&&j<a) f+=e[i][j]; if(i+1>=0&&i+1<a&&j>=0&&j<a) f+=e[i+1][j]; if(i-1>=0&&i-1<a&&j>=0&&j<a) f+=e[i-1][j]; if(i>=0&&i<a&&j+1>=0&&j+1<a) f+=e[i][j+1]; if(i>=0&&i<a&&j-1>=0&&j-1<a) f+=e[i][j-1]; if(i+1>=0&&i+1<a&&j+1>=0&&j+1<a) f+=e[i+1][j+1]; if(i-1>=0&&i-1<a&&j+1>=0&&j+1<a) f+=e[i-1][j+1]; if(i+1>=0&&i+1<a&&j-1>=0&&j-1<a) f+=e[i+1][j-1]; if(i-1>=0&&i-1<a&&j-1>=0&&j-1<a) f+=e[i-1][j-1]; cout<<f<<" "; } cout<<endl; } return 0; }
- 1
信息
- ID
- 295
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 8
- 标签
- 递交数
- 21
- 已通过
- 4
- 上传者