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<iostream> using namespace std; #define MAX 1001 int main() { int len1,len2,i,j; char s1[MAX],s2[MAX]; int dp[MAX][MAX]; while(cin>>s1+1>>s2+1) { len1=strlen(s1); len2=strlen(s2); // cout<<len1<<endl<<len2<<endl; for(i=0;i<len1;i++) { dp[i][0]=0; } for(j=0;j<len1;j++) { dp[0][j]=0; } for(i=1;i<len2;i++) { for(j=1;j<len2;j++) { if(s1[i]==s2[j]) dp[i][j]=dp[i-1][j-1]+1; else { dp[i][j]=dp[i-1][j]>dp[i][j-1]?dp[i-1][j]:dp[i][j-1]; } } } cout<<dp[len1-1][len2-1]<<endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator