1120 Friend Numbers (20 分)(进制转换水题)
作者:互联网
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <vector>
#include <set>
#include <cmath>
using namespace std;
set<int> ans;
int main()
{
int n;
cin >> n;
for (int i = 0; i<n; i++) {
int t, sum = 0;
cin >> t;
while (t) {
sum += t%10;
t /= 10;
}
ans.insert(sum);
}
cout << ans.size() << endl;
set<int>::iterator it;
for (it = ans.begin(); it != ans.end(); it++) {
if (it == ans.begin()) {
printf("%d", *it);
} else {
printf(" %d", *it);
}
}
cout << endl;
return 0;
}
标签:cout,水题,1120,sum,printf,int,Numbers,ans,include 来源: https://blog.csdn.net/NCUscienceZ/article/details/100101993