用集合记录
用取余开路
用除等于循环
#include<iostream> #include<set> using namespace std; int main() { int n; cin >> n; set<int> set1; int ans = 0; while(n > 0) { int temp = n % 10; if (set1.count(temp) == 0) { ans = ans * 10 + temp; set1.insert(temp); } n /= 10; } cout << ans << endl; return 0; }