解题记录:Sorting

题目:
Don’t be nervous! It is a very easy problem! My business here is to give you some numbers, and to sort them is your business. Attention, I just want the first number of each m numbers.

输入:
The input file will consist of series data sets. Each data set has two parts. The first part contains two non-negative, n (1<=n<=10,000) and m (1<= m <= n), representing the total of numbers you will get and interval of the output sorted list. The second part contains n positive intergers. I am sure that each interger in this part will less than 2,000,000.
The input is terminated by a line with two zeros.

输出:
For each data set, you should output several numbers in one line. After you get the sorted list, you should output the first number of each m numbers, and you should print exact one space between two adjacent numbers. And please make sure that there should NOT be any blank line between outputs of two adjacent data sets.

样例输入:

8 2
3 5 7 1 8 6 4 2
0 0

样例输出:

1 3 5 7

我的代码:http://putpan.com/fs/851220718949126b367/


猜你喜欢

转载自blog.csdn.net/weixin_43751110/article/details/86671012