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

提取不重复的整数

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

#include <iostream>
#include<algorithm>
#include<unordered_set>
using namespace std;

int main() {
    int nums;
    cin>>nums;
    string str=to_string(nums);
    unordered_set<char>set;
    reverse(str.begin(),str.end());
    string res="";
    for(char c: str){
        if(set.count(c)!=1){
            res+=c;
            set.insert(c);
        }
    }
    cout<<stoi(res)<<endl;
    return 0;

    
    
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

06-27 18:53
门头沟学院 Java
这样才知道自己不适合搞代码,考公去咯
只爱喝白开水:我也发现不适合搞代码,打算转非技术方向了
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
05-28 12:15
点赞 评论 收藏
分享
05-30 12:03
山西大学 C++
offer来了我跪着...:不是骗子,等到测评那一步就知道为啥这么高工资了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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