题解 | 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")
查看6道真题和解析