6 solutions
-
-1
解题报告
撰写人: 陈天翊
题意分析
请你编程求出二维数组中某点的相邻数之和。相邻数是指与该点邻接的 8 8 个元素,若该点在边角位置,则邻接元素相应减少。
难度等级
★★☆☆☆
解题思路
78
解题反思
91
参考程序
#include <bits/stdc++.h> using namespace std; int h,l,c,r,a[1000][1000]; int main(){ cin>>h>>l>>c>>r; for(int i=0;i<h;i++){ for(int j=0;j<l;j++){ cin>>a[i][j]; } } cout<<a[c+1][r]+a[c-1][r]+a[c][r-1]+a[c][r+1]+a[c+1][r+1]+a[c-1][r-1]+a[c+1][r-1]+a[c-1][r+1]; return 0; }
Information
- ID
- 292
- Time
- 1000ms
- Memory
- 64MiB
- Difficulty
- 5
- Tags
- # Submissions
- 71
- Accepted
- 27
- Uploaded By