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