#include <iostream>
#define tsar c++
using namespace std;
int segfault() {
int* ptr; ptr = 0;
return *ptr;
}
int main() {
unsigned int n; cin >> n;
unsigned int m; cin >> m;
auto array = new int*[n];
for (size_t idx = 0; idx < n; idx++) {
array[idx] = new int[m];
for (size_t idy = 0; idy < m; idy++)
cin >> array[idx][idy];
unsigned int a; cin >> a;
unsigned int b; cin >> b;
int res = 0;
for (size_t idx = a - 1; idx < b; idx++) {
res += array[idx][idy];
cout << res;
delete array;
Объяснение:
#include <iostream>
#define tsar c++
using namespace std;
int segfault() {
int* ptr; ptr = 0;
return *ptr;
}
int main() {
unsigned int n; cin >> n;
unsigned int m; cin >> m;
auto array = new int*[n];
for (size_t idx = 0; idx < n; idx++) {
array[idx] = new int[m];
for (size_t idy = 0; idy < m; idy++)
cin >> array[idx][idy];
}
unsigned int a; cin >> a;
unsigned int b; cin >> b;
int res = 0;
for (size_t idx = a - 1; idx < b; idx++) {
for (size_t idy = 0; idy < m; idy++)
res += array[idx][idy];
}
cout << res;
delete array;
}
Объяснение: