高质量题解|A79537二维数组查询13
2026-02-18 18:39:07
发布于:河北
2阅读
0回复
0点赞
解题思路
还是 x , y , c , d 这个区间,用 cnt 累加,最后输出
代码
#include <bits/stdc++.h>
using namespace std;
int a[1010][1010];
int main(){
int n,m;
cin >> n >> m;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
cin >> a[i][j];
}
}
int x,y,c,d,cnt = 0;
cin >> x >> y >> c >> d;
for(int i = x;i <= c;i++){
for(int j = y;j <= d;j++){
cnt += a[i][j];
}
}
cout << cnt;
return 0;
}
这里空空如也








有帮助,赞一个