www.bersaty.com
摘要: 有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少?输入n,接着n行,nusing namespace std;int main(){ int n,a[210],t[210]={0},i,j; cin>>n; for(i=1;i>a[j]; for(j=i;j>=1;j--) t[j]=a[j]+(t[j-1]>t[j]? t[j-1]:t[j]); } j=0; for(i=1;i<n;i++) if(j<t[i]) ... 阅读全文
posted @ 2011-11-14 23:40 bersaty 阅读(313) 评论(0) 推荐(0)