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 |
大虾们帮帮忙啊!我急死了!题会做……但是不懂输入数据时什么意思……到底要输入多少个啊?该怎么写啊?(附code)#include <iostream> #include <cstring> using namespace std; int max(int a,int b) { if(a>b) return a; else return b; } int main() { int la,lb,f[500][500]; char a[500],b[500]; cin>>a>>b; la=strlen(a); lb=strlen(b); for(int i=1;i<=la;i++) for(int j=1;j<=lb;j++) f[i][j]=0; for(int i=1;i<=la;i++) for(int j=1;j<=lb;j++) { if(a[i-1]==b[j-1]) f[i][j]=f[i-1][j-1]+1; else f[i][j]=max(f[i-1][j],f[i][j-1]); } cout<<f[la][lb]; return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator