-->
当前位置:首页 > 题库

PROGRAMMING:sort

Luz5年前 (2021-05-10)题库481
Today, Xiao Lin encountered a problem. He needs to sort n groups of data, which is stored in a linked list. Now Kobayashi wants you to help him sort the data in ascending order.
###Input format:
The input contains a test data. The first line of the sample has two integers n (1 < = n < 10 ^ 5), head (0 < = head < 10 ^ 5), and the next N lines. The data format of each line is as follows:
address data next 。
Address (0 < = address < 10 ^ 5) represents the address of the node, data (0 < = Data < 10 ^ 5) is the data field of the node, and next (0 < = next < 10 ^ 5) is the address of the next node of the node,
When next is empty, it is represented by - 1, which may contain invalid data
###Output format:
Output each node after ascending order in one line, output format:
address data next ,
Address and next need to output five bits. If less than five bits are filled with 0, the interval between the two nodes is used. There are no extra spaces and line breaks at the end of the line
###Input example:
```in
6 00001
33333 3 44444
00001 4 22222
55555 2 -1
00002 6 00003
22222 1 33333
44444 5 55555
```
###Output example:
```out
22222 1 55555->55555 2 33333->33333 3 00001->00001 4 44444->44444 5 -1
```






answer:If there is no answer, please comment