题解 | #提取不重复的整数#

提取不重复的整数

https://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1

利用set做重复char的筛选,之后作为判定条件,反向输出。
#include <iostream>
#include <string>
#include <set>
using namespace std;
 
int main(){
    char b;
    set<char> s;
    string str;
    cin>>str;
    int len=str.length();
    for(int i=(len-1);i>=0;i--)
    {
        if (s.find(str[i])==s.end())
        {
            cout<< str[i];
         s.insert(str[i]);
        }   
    }
    return 0;
}
#提取不重复的整数#
全部评论

相关推荐

hwwhwh:同双非,有大厂实习其实也没啥用,主要看运气,等就行了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务