10-Sort 4 statistic seniority

Source: Internet
Author: User

A very simple question, the use of bucket sorting comprehension method, the number of employees is very large, the range of seniority in [0, 50].

Create each bucket with seniority, and classify each employee's seniority as a different bucket.

The seniority of a given company's N employees requires that the number of employees in each seniority segment be output by seniority.

Input format:

The input first gives a positive integerN(≤10? ^5?? ), which is the total number of employees, followed by N integers, that is, the seniority of each employee, in [0, 50].

Output format:

The number of employees per seniority is output in ascending order of seniority, in the form of: "Seniority: Number of people". Each item occupies a row. If the number is 0, the item is not exported.

Input Sample:
810 2 0 5 7 2 5 2
Sample output:
0:12:35:27:110:1

1#include <stdio.h>2 3 intMain ()4 {5     intN,workage;6     intworkyear[ -] = {0};7scanf"%d",&N);8      for(inti =0; i < N; i++) {9scanf"%d",&workage); Tenworkyear[workage]++; One     } A      for(inti =0; I <Wuyi; i++) { -         if(Workyear[i]) -printf"%d:%d\n", I, workyear[i]);  the     } -     return 0;  -}

 

10-Sort 4 statistic seniority

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.