门禁系统

来源:互联网 发布:淘宝网自助服务中心 编辑:程序博客网 时间:2024/04/28 11:18

/*

问题描述
  涛涛最近要负责图书馆的管理工作,需要记录下每天读者的到访情况。每位读者有一个编号,每条记录用读者的编号来表示。给出读者的来访记录,请问每一条记录中的读者是第几次出现。
输入格式
  输入的第一行包含一个整数n,表示涛涛的记录条数。
  第二行包含n个整数,依次表示涛涛的记录中每位读者的编号。
输出格式
  输出一行,包含n个整数,由空格分隔,依次表示每条记录中的读者编号是第几次出现。
样例输入
5
1 2 1 1 3
样例输出
1 1 2 3 1
评测用例规模与约定
  1≤n≤1,000,读者的编号为不超过n的正整数。

*/

#include"stdio.h"



int main()
{
    int num_number, num[1000], count_num[100][2], i,len,j;


    scanf("%d", &num_number);


    for(i = 0; i < num_number; i++)
    {
        scanf("%d", &num[i]);
    }


    len = -1;
    for(i = 0; i< num_number; i++)
    {
        if(len >= 0)
        {
            for(j = len; j>=0; j--)
            {
                if(num[i] == count_num[j][0])
                {
                    count_num[j][1] += 1;
                    printf("%d ", count_num[j][1]);
                    break;
                }
            }
            if(j == -1)
            {
                len++;
                count_num[len][0] = num[i];
                count_num[len][1]=1;
                printf("%d ", count_num[len][1]);
            }
        }
        else{
            len++;
            count_num[len][0] = num[i];
            count_num[len][1]=1;
            printf("%d ", count_num[len][1]);
        }
    }






    return 0;
}
0 0