| ||||||||||
| 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<stdio.h>//求公共子串
int main()
{
char a[1000]={0},b[1000]={0};
int m=-1,n=0,i=0,j=0;
scanf("%s",&a);
while(1)
{
m=-1;
n=0;
i=0;
j=0;
for(i=0;i<1000000&&a[i]!=0;i++)
{
if(m==-1)
{
b[0]=a[0];
m=0;
continue;
}
if(n>m)
{
n=0;
}
if(a[i]!=b[n])
{
for(j=0;j<=i;j++)
{
b[j]=a[j];
}
n=0;
m=i;
continue;
}
n++;
}
if(n!=m+1)
{
printf("%d",1);
scanf("%s",&a);
continue;
}
printf("%d",i/(m+1));
scanf("%s",&a);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator