solution
给出n个整数,统计可能的位数和,并按升序输出(考虑用set实现)
#include<iostream>
#include<set>
using namespace std;
int main(){set<int> st;int n, x, sum;scanf("%d", &n);while(n--){sum = 0;scanf("%d", &x);while(x){sum += x % 10;x /= 10;}st.insert(sum);}printf("%d\n", st.size());for(set<int>::iterator it = st.begin(); it != st.end(); it++){if(it != st.begin()) printf(" ");printf("%d", *it);}return 0;
}