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

提取不重复的整数

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

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

int main() {
    int a, b;
    cin >> a;
    unordered_set<int> st;
    int res = 0;
    while(a > 0){
        b = a%10;
        a /= 10;
        if(st.count(b) == 0){
            res = res*10 + b;
            st.emplace(b);
        }
    }

    cout << res << endl;

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

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务