1346 位数和排序


Submit solution

Points: 100
Time limit: 1.0s
Memory limit: 32M

Problem types
Allowed languages
C, C++, Java, Python

Description

将每组整数按各位数字和的大小进行排序输出。数字和排序是指,如果两个整数的数字和不相等,则数字和大者排在前,若数字和相等,则整数值大者排在前。

Input

输入一些整数组,第一个数N表示该数组有N个数,随后输入N个整数(0<N<=999)。若N为0,则程序运行结束。

Output

按所给的比较方法从大到小的顺序输出N个整数,每个数之间用一个空格隔开,行末无空格。

Sample

Input

5
35 27 88 61 23
8
11 45 54 31 24 76 999 1000
0

Output

88 27 35 61 23
999 76 54 45 24 31 11 1000

Source: 浙工大2008C++期中竞赛


Comments

There are no comments at the moment.