Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么过不了?#include<stdio.h> main(){ int max,n,i,j; scanf("%d",&n); int m[102][102],a[102][102]; for(i=1;i<=n;i++){ for(j=1;j<=i;j++) scanf("%d",&m[i][j]); } a[1][1]=m[1][1]; for(i=2;i<=n;i++){ a[i][1]=m[i][1]+a[i-1][1]; for(j=2;j<=i-1;j++){ if(a[i-1][j]<=a[i-1][j-1]){ a[i][j]=m[i][j]+a[i-1][j-1]; }else{ a[i][j]=m[i][j]+a[i-1][j]; } a[i][i]=a[i-1][i-1]+m[i][i]; } } max=a[n][1]; for(i=2;i<=n;i++){ if(a[n][i]>max) max=a[n][i]; } printf("%d",max); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator