码迷,mamicode.com
首页 > 编程语言 > 详细

c++sting类 在字符串中找相同的字符 并且把他删除

时间:2016-11-26 15:11:20      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:include   字符串   c/c++   stl容器   

 

#include<iostream>
#include<string>

int main()
{
    string str=;  //十个字符串
    string::iterator it;   //stirng 迭代
    int index=str.find("\\");
    int x=0;
    while(inedx!=-1)
    {
        if((index-1)==0)  //前面的减去后面的是1那么就是相同
        {
            it=str.begin();
            cout<<"找到相同的了"
            str.erase(it+index);
        }
        x=index;
        index=str.find("\\",index+1);
    }
    
   return 0;
}


本文出自 “12148490” 博客,请务必保留此出处http://12158490.blog.51cto.com/12148490/1876797

c++sting类 在字符串中找相同的字符 并且把他删除

标签:include   字符串   c/c++   stl容器   

原文地址:http://12158490.blog.51cto.com/12148490/1876797

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!