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 |
为什么wa#include <iostream.h> #include <string.h> int cal(char *ms,char *ds){ int a=strlen(ms); int b=strlen(ds); int i,j; int lenth=101; if(a>b){ for(j=0;j<=a-b;j++){ for(i=0;i<b;i++){ if(int(ms[j+i]-'1')*int(ds[i]-'1'))break; } if(i==b)lenth=a; } for(i=b-2;i>=0;i--){ for(j=0;j<=i;j++){ if(int(ms[i-j]-'1')*int(ds[b-j-1]-'1'))break; } if(j==i+1)lenth=lenth>(a+b-i-1)?(a+b-i-1):lenth; } for(i=a-b+1;i<a;i++){ for(j=0;j<a-i;j++){ if(int(ms[i+j]-'1')*int(ds[j]-'1'))break; } if(j==a-i)lenth=lenth>(b+i)?(b+i):lenth; } } if(b>a){ for(j=0;j<=b-a;j++){ for(i=0;i<a;i++){ if(int(ds[j+i]-'1')*int(ms[i]-'1'))break; } if(i==a)lenth=b; } for(i=a-2;i>=0;i--){ for(j=0;j<=i;j++){ if(int(ds[i-j]-'1')*int(ms[a-j-1]-'1'))break; } if(j==i+1)lenth=lenth>(a+b-i-1)?(a+b-i-1):lenth; } for(i=b-a+1;i<b;i++){ for(j=0;j<b-i;j++){ if(int(ds[i+j]-'1')*int(ms[j]-'1'))break; } if(j==b-i)lenth=lenth>(a+i)?(a+i):lenth; } } if(a==b){ for(i=0;i<a;i++){ if(int(ds[i]-'1')*int(ms[i]-'1'))break; } if(i==a)lenth = a; for(i=b-2;i>=0;i--){ for(j=0;j<=i;j++){ if(int(ms[i-j]-'1')*int(ds[b-j-1]-'1'))break; } if(j==i+1)lenth=lenth>(a+b-i-1)?(a+b-i-1):lenth; } for(i=1;i<a;i++){ for(j=0;j<a-i;j++){ if(int(ms[i+j]-'1')*int(ds[j]-'1'))break; } if(j==a-i)lenth=lenth>(b+i)?(b+i):lenth; } } lenth=lenth>(a+b)?(a+b):lenth; return lenth; } void main(){ char ms[100],ds[100]; cin.getline(ms,100); cin.getline(ds,100); cout<<cal(ms,ds)<<"\n"; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator