题目
思路:
准备一个空数组存储朋友证号
每次判断此证号是否已经存在,如果存在,则不存入
按要求输出
代码
def str_to_num(str_):
sum_=0
for i in str_:
sum_=sum_+int(i)
return sum_
num_=int(input())
condinate_friend=list(input().split(' '))
friend_num=0
friend_id=[]
for i in range(0,num_):
if str_to_num(condinate_friend[i]) not in friend_id:
friend_num=friend_num+1
friend_id.append(str_to_num(condinate_friend[i]))
print(friend_num)
friend_id=sorted(friend_id)
print((' ').join([str(i) for i in friend_id]))