JYW2011 @ 2023-05-19 21:29:43
用的是顺推
#include<iostream>
using namespace std;
int a[101][101],n;
int main() {
cin>>n;
for(int i=1; i<=n; i++)
for(int j=1; j<=i; j++)
cin>>a[i][j];
for(int i=n-1; i>=1; i--)
for(int j=1; j<=i; j++)
a[i][j]=a[i][j]+max(a[i+1][j],a[i+1][j+1]);
cout<<a[1][1];
return 0;
}
by JYW2011 @ 2023-05-19 21:31:52
用Python 3过的,不过那对我没有用,我学的是C++
by _XiaY_ @ 2023-05-19 21:32:04
你数组开小了,题目里说
by JYW2011 @ 2023-05-19 21:36:31
谢谢您
by JYW2011 @ 2023-05-19 21:37:42
已关