10- seniority statistics sorting 4 (20 points)

Given the company seniority N employees, in increasing order of length of service required by the output of each segment length of service the number of employees.

Input formats:

Firstly, input a positive integer N ( . 1 0 ^. 5) , i.e., the total number of employees; subsequently given N integers, i.e., length of service of each employee, in the range [0, 50].

Output formats:

The number of employees for each output seniority ascending order of seniority, the format is: "length of service: Number." Each separate line. If the number is 0 is not output.

Sample input:

8
10 2 0 5 7 2 5 2

Sample output:

0:1
2:3
5:2
7:1
10:1

#include<cstdio>
const int maxn = 60;

int main ()
{
    int age[maxn] = {0};
    int n;
    scanf("%d",&n);
    
    int nAge;
    for (int i = 0; i < n; i++)
    {
        scanf("%d",&nAge);
        if (nAge >= 0 && nAge <= 50)
        {
            Age [NAge] Tasutasu ;
        }
    }
    
    for (int i = 0; i <= 50; i++)
    {
        if (age[i] != 0)
        {
            printf("%d:%d\n", i, age[i]);
        }
    }
    return 0;
}

 

 

Guess you like

Origin www.cnblogs.com/wanghao-boke/p/11915329.html