面试题35—相关题目1

来源:互联网 发布:软件著作权发表日期 编辑:程序博客网 时间:2024/06/06 09:16

**题目:删掉字符串中所有重复的字符
代码示例:**

#include<iostream>#include<vector>#include<string>using namespace std;int main(){    string str = "gooogllergtigle";    vector<bool> flag(256, false);    for (int i = 0; i < str.length(); i++)    {        char ch = str[i];        if (!flag[ch])            cout << ch;        flag[ch] = true;    }    cout << endl;}
原创粉丝点击