| ||||||||||
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 |
Re:要疯掉了,同样的代码怎么一会儿是runtime error 一会儿是AC呢,害得我找错误半天.In Reply To:要疯掉了,同样的代码怎么一会儿是runtime error 一会儿是AC呢,害得我找错误半天. Posted by:fql5188 at 2008-07-16 01:47:17 > runtime error代码(原封不动的copy过来了): > #include<stdio.h> > char ch[5001]; > short min[5000][5000]={0}; > int minnum(short a,short b) > { > return a>b?b:a; > } > int main() > { > short n; > short i,j,k; > scanf("%d",&n); > scanf("%s",ch); > for(i=n-1;i>=0;i--) > for(j=i;j<n;j++) > { > if(ch[i]==ch[j]) > min[i][j]=min[i+1][j-1]; > else > min[i][j]=1+minnum(min[i+1][j],min[i][j-1]); > } > printf("%d\n",min[0][n-1]); > return 0; > } > 这是哪份AC的代码: > #include<stdio.h> > char ch[5001]; > short min[5000][5000]={0}; > int minnum(short a,short b) > { > return a>b?b:a; > } > int main() > { > short n; > short i,j,k; > scanf("%d",&n); > scanf("%s",ch); > for(i=n-1;i>=0;i--) > for(j=i+1;j<n;j++) > { > if(ch[i]==ch[j]) > min[i][j]=min[i+1][j-1]; > else > min[i][j]=1+minnum(min[i+1][j],min[i][j-1]); > } > printf("%d\n",min[0][n-1]); > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator