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 菜鸟代码写的不好大家见笑 GCC#include "stdio.h" int x1,y1; char z,x[600],y[600]; int a[600][600]; void main() { int i,j; int seek(int i,int j); int max(int x,int y); while(1){ x1=0; y1=0; for(i=0;i<=599;i++) for(j=0;j<=599;j++){ a[i][j]=-1;} while(1){ z=getchar(); if(z!=' '){ x1++; x[x1]=z; } else break; } while(1){ z=getchar(); if(z!=' '){ y1++; y[y1]=z; break; } } while(1){ z=getchar(); if(z!='\n'){ y1++; y[y1]=z; } else break; } printf("%d\n",seek(x1,y1)); } } int seek(int i,int j) { if(a[i][j]!=-1) return a[i][j]; else if(i==0||j==0) return a[i][j]=0; else{ if(x[i]==y[j]) return a[i][j]=1+seek(i-1,j-1); else return a[i][j]=max(seek(i-1,j),seek(i,j-1)); } } int max(int x,int y) { return x>y?x:y; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator