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:请大家帮帮我吧,我总是REIn Reply To:请大家帮帮我吧,我总是RE Posted by:hugh_USTC at 2005-02-26 10:03:36 > #include <iostream.h> > #include <string.h> > void main() > { > int C[99][99]; > char X[100]; > char Y[100]; > while (cin>>X+1>>Y+1) > { > int m = strlen(X+1), n = strlen(Y+1); > int i = 0; > for(i=0;i<=m;i++) C[i][0] = 0; > for(i=0;i<=n;i++) C[0][i] = 0; > for(i=1;i<=m;i++) > { > for(int j=1;j<=n;j++) > { > if (X[i] == Y[j]) > { > C[i][j] = C[i-1][j-1] + 1; > } > else if (C[i-1][j] >= C[i][j-1]) > { > C[i][j] = C[i-1][j]; > } > else > { > C[i][j] = C[i][j-1]; > } > } > } > cout << C[m][n] << endl; > } > } 你的数组开得太小了,开到500就能过 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator