nyoj-673-Puzzle (Array marker)

Source: Internet
Author: User

Goku Puzzle time limit: +Ms | Memory Limit:65535KB Difficulty:2
Describe

Since the Wu space on the Grand holy, Monkey Monkey Sun on the Huaguoshan can also taste all kinds of heavenly fruit God wine, so monkey Monkey Sun's physique also got a very good improvement, height age also got a great increase. One day Goku is OK, to lead his monkey monkey grandchildren go out to travel, in order to maintain the image of Huaguoshan, an elder monkey suggested that the monkeys are ranked by the height of a team.

The monkeys are so anxious to start, how to quickly arrange the team so that the magic of the Great holy headache unceasingly. Now ask you to be the king of the King of the King of Goku to help him sort.


Input
the first line of data consists of an integer T (0<t<=50), which represents a T-group test data;
The next group of data in the first row has two integers, n,m (0<n<=1000000), respectively, representing the number of monkeys and the maximum height (height in centimeters, assuming that all monkeys are not more than 1 meters tall). Second act n the height of a monkey, separated by a space.
Output
One
row per set of outputs.
From small to large output all the height of the monkeys, separated by a space. (There is no space behind the last height).
Sample input
25 1002 4 5 1 310 1009 8 5 1 10 2 3 4 9 8
Sample output
1 2 3 4 51 2 3 4 5 8 8 9 9 10

Problem Solving Ideas:

Careful observation of the topic, you will find that the topic gave a maximum height m, if not to the data this problem can also be done, why to give this data?

The answer must be that this data is useful, which is the critical point of the array tag. We can use the array subscript to mark height, array values to store the number of monkeys corresponding to the height, and then the other is to pay attention to how to output the required format, I believe everyone will this format!

Code

#include <stdio.h> #include <string.h>int high[110];int main () {int t;int n,m;int i,j,k;int now;scanf ("%d", &t), while (t--) {scanf ("%d%d", &n,&m), memset (high,0,sizeof), and for (i=0;i<n;i++) {scanf ("%d", &now); high[now]++;} for (i=0;i<=m;i++)//To add m to the range {while (High[i]) {printf ("%d", I), High[i]--;if (n!=0)    printf (""); n--;}} printf ("\ n");} return 0;}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

nyoj-673-Puzzle (Array marker)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.