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> int total=0; void DP(int i,int j,int sum ,int data[351][351]) { sum+=data[i][j]; if(i==0&&j==0) { if(total<sum) { total=sum; } } if(j-1>=0&&i-1>=0&&data[i-1][j-1]>=data[i-1][j]) { DP(i-1,j-1,sum,data); } if(j-1>=0&&i-1>=0&&data[i-1][j-1]<data[i-1][j]) { DP(i-1,j,sum,data); } if(i!=0&&j==0) { DP(i-1,j,sum,data); } } int main() { int n,i,j; int data[351][351]; scanf("%d",&n); for(i=0;i<n;i++) for(j=0;j<i+1;j++) scanf("%d",&data[i][j]); for(i=0;i<n;i++) DP(n-1,i,0,data); printf("%d\n",total); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator