问题遇到的现象和发生背景
二维数组前缀和 然后n是行数,m是列数,t是询问次数,x1,x2,y1,y2表示询问对应的下标,但是程序出错了(输入都未能完结)
#include
using namespace std;
using ll = long long;
signed main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n, m, t;
cin >> n >> m >> t;
vector> a(n + 1, vector(m + 1, 0));
for (ll i = 1; i <= n; ++i)
{
for (ll j = 1; j <= m; ++j)
{
cin >> a[i][j];
a[i][j] = a[i - 1][j] + a[i][j - 1] + a[i][j] - a[i - 1][j - 1];
}
}
while (t--)
{
ll x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
cout << (a[x2][y2] - a[x2][y1 - 1] - a[x1 - 1][y2] + a[x1 - 1][y1 - 1]) << "\n";
}
return 0;
}
用代码块功能插入代码,请勿粘贴截图
运行结果及报错内容 输入都输入不完