题解 | #提取不重复的整数#
提取不重复的整数
https://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1
#include <iostream> #include <set> using namespace std; int ReserveandRemoveDuplicates(int num) { set<int> seen; int result = 0; while(num>0) { int digit = num % 10; if(seen.find(digit) == seen.end()) { seen.insert(digit); result = result * 10 + digit; } num = num / 10; } return result; } int main() { int num; while (cin >> num) { // 注意 while 处理多个 case cout << ReserveandRemoveDuplicates(num) << endl; } } // 64 位输出请用 printf("%lld")