Advertisement

Case 7-1.4: Track Tenure (20 points)

阅读量:

已知某企业共有N名职员,其任职年限各不相同,现需按照工作年限由低到高的顺序,统计并列出各段工龄区间内的员工人数。

输入格式:

初始输入包含一个正整数N(≤10 5),表示公司内员工的总数量;接下来提供N个数值,分别代表每位员工的工龄,其取值范围限定在[0, 50]之间。

输出要求为:
依据工龄从小到大的顺序,依次列出每个工龄对应的员工人数,格式应为“工龄:人数”。每一行仅展示一个条目。若某工龄对应的员工数量为零,则无需显示该条目。

输入示例:
8
10 2 0 5 7 2 5 2
输出示例:
0:1
2:3
5:2
7:1
10:1

代码:

复制代码
    #include<iostream>
    #include<string>
    #include<cstdio>
    #include<cmath>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    int f[55];
    int n , k , tip = 0;
    int main()
    {
    cin>>n;
    memset( f , 0 , sizeof(f));
    for(int i = 1 ; i <= n ; 

全部评论 (0)

还没有任何评论哟~