题解 | #提取不重复的整数#
提取不重复的整数
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")