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

提取不重复的整数

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

#include <iostream>
#include<algorithm>
#include <string>
#include <vector>
using namespace std;

int main() {
    int a;
    while (cin >> a) { // 注意 while 处理多个 case
        string str=to_string(a);
        if(str.back() == '0')
        {
            return 0;
        }
        reverse(str.begin(),str.end());
        vector<char>vec;
        string result;
        for (auto c : str)
        {
            if (find(vec.begin(),vec.end(),c)==vec.end())
            {
                vec.push_back(c);
                result+=c;
            }
        }
        cout<<stoi(result)<<endl;
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

没hc还海面!呜呜,避雷
回收旧报纸:没有海面吧,我做完笔试有一个多月了,还没消息
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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