关于迭代器和容器的问题

[复制链接]
查看11 | 回复0 | 2009-2-23 21:27:00 | 显示全部楼层 |阅读模式
才入门,写了一段程序将第一次输入的字符串中在第二次输入的字符串相等的串用"_"代替.
#include
#include
#include
using namespace std;
int main()
{
string a, b;
cout > a;
cout > b;
string::size_type pos = 0;
string::iterator iter = a.begin();
string::size_type len = b.size();
int temp;
while(iter != a.end())
{

pos = a.find(b);

a.replace(pos, (int)len, "_");

for(temp = ((int)pos + len); temp > 0; temp--)

iter++;
}
cout 容器和迭代器的头文件...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行