C++程序:要实现如下功能,输入字符串s1,s2,在s1中查找s2,并打印每个S2出现的位置,统计匹配的个数.
C++程序:要实现如下功能,输入字符串s1,s2,在s1中查找s2,并打印每个S2出现的位置,统计匹配的个数.
日期:2013-04-07 13:06:56 人气:1
c++ 用string 标准实现方式:
#include #include using namespace std;int main(){ string str = "abcded fgeduied"; size_t pos = 0; int ncount = 0; while(1) { pos=((ncount==0)?0:pos+1);//第一次pos=0,再一次则要偏移一个位置了 pos = str.fin