[Huawei OD Machine Test Real Questions] Disk Capacity (java) 100% pass rate [2023 (Volume B) 100 points]

Disk capacity

Question description

Commonly used capacity units of disks are M, G, and T.
The conversion relationship between them is 1T = 1024G, 1G = 1024M.
Now given the capacities of n disks, please sort them stably from small to large.
For example, given 5 disk capacity

5
1T
20M
3G
10G6T
3M12G9M

The sorted result is

20M
3G
3M12G9M
1T
10G6T

Note that units can appear repeatedly.
The capacity represented by the above 3M12G9M is equal to 3M12G9M and 12M12G.

Enter description

The first line of input contains an integer n, 2 <= n <= 100, indicating the number of disks.
The next n lines, each line has a string, 2 < length < 30, indicating the disk capacity,
consisting of one or more substrings in the format of MV, where M represents the capacity size and V represents the capacity unit,
such as 20M, 1T.
Disk capacity is a positive integer ranging from 1 to 1024, in units of M, G, and T.

Output description

Output n lines
represents the result of sorting n disk capacities.

Example 1

enter

3
1G
2G
1024M

Guess you like

Origin blog.csdn.net/weixin_45541762/article/details/132925178