You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.3 KiB

2 years ago
#include <bits/stdc++.h>
/*
5 6
1 0 1 0 0 0
0 1 0 1 0 0
1 0 0 0 1 0
0 1 0 0 0 1
1 0 1 0 0 0
II
5 6
1 0 1 0 0 0 2 0 4 0 0 0
0 1 0 1 1 0 0 1 0 3 1 0
1 0 0 0 1 0 3 0 0 0 2 0
0 1 0 0 0 1 0 2 0 0 0 1
1 0 1 0 0 0 1 0 1 0 0 0
5 6
1 0 1 0 0 0
0 1 0 1 1 0
1 0 0 0 1 0
0 1 0 0 0 1
1 0 1 0 0 0
III
5 6
1 0 1 0 0 0
0 1 0 1 1 0
1 0 0 0 1 0
0 1 0 1 0 1
1 0 1 0 1 0
*/
using namespace std;
const int N = 110;
int a[N][N];
int res;
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];
//直接在原数组上递推
for (int i = n; i >= 1; i--) //从倒数第二行开始
for (int j = 1; j <= m; j++) //这个需要考虑一下边界问题
if (a[i][j]) //只有当前位置大于0才有考虑的价值
a[i][j] += a[i + 1][j + 1]; //递推式
cout << "====================" << endl;
//打印出这个新的递推数组看看是什么情况
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++)
cout << a[i][j] << " ";
cout << endl;
}
return 0;
}