| ||||||||||
| 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>
#include <string>
using namespace std;
int main()
{
string s;
while(cin>>s && s!=".")
{
unsigned long i,j,len=s.length();
bool found=false;
for(i=1;i<len;++i)
if(s[0]==s[i])
{
found=true;
break;
}
if(!found)
cout<<1<<endl;
else
{
int count=1;
string s2;
s2=s.substr(0,i);
int len2=s2.length();
string::size_type flag;
for(j=i;j<len;j=flag+1)
{
flag=s.find(s2,j);
if(flag==string::npos)
break;
else
++count;
}
cout<<count<<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