Data structure and algorithm topic set (Chinese)--5-13 statistical seniority (20 points)--bucket sequencing

Source: Internet
Author: User

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

Input format:

The input first gives a positive integerNn ( \le 10^5< Span class= "base textstyle uncramped" >≤10?5?? ), that is, the total number of employees; then give n< Span class= "Strut bottom" >n integers, that is, the seniority of each employee, in the range of [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
 
    • Time limit: 400ms
    • Memory Limit: 64MB
    • Code length limit: 16kB
    • Procedure: System default
    • Chen
    • Unit: Zhejiang University
#include <iostream>using namespacestd;intMain () {intage[Wuyi]={0}; intn,p; CIN>>N;  for(intI=0; i<n;i++) {cin>>p; AGE[P]++; }     for(intI=0;i<Wuyi; i++){        if(age[i]==0)Continue; cout<<i<<":"<<age[i]<<Endl; }    return 0;} 

Please choose the g++ compiler

 

Data structure and algorithm topic set (Chinese)--5-13 statistical seniority (20 points)--bucket sequencing

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.