int calString(string A)
{
unsigned int cnt = 0;
string del = "coder";
string::size_type pos = 0;
while((pos = A.find(del,pos))!=string::npos)
{
++cnt;
pos = pos+del.size();
}
return cnt;
}
代码简单,不解释,写下备用。