Love丶FFC's Blog

CCF-CSP_20141201:门禁系统

2019-09-11 21:59:31
阅读:983   •   评论:5
标签:,

问题描述

涛涛最近要负责图书馆的管理工作,需要记录下每天读者的到访情况。每位读者有一个编号,每条记录用读者的编号来表示。给出读者的来访记录,请问每一条记录中的读者是第几次出现。

输入格式

输入的第一行包含一个整数n,表示涛涛的记录条数。

第二行包含n个整数,依次表示涛涛的记录中每位读者的编号。

输出格式

输出一行,包含n个整数,由空格分隔,依次表示每条记录中的读者编号是第几次出现。

样例输入

5
1 2 1 1 3

样例输出

1 1 2 3 1

评测用例规模与约定

1≤n≤1,000,读者的编号为不超过n的正整数。

编程语言:Java

解题思想:

1.从第二个输入的编号开始进行判断。

2.控制输出格式

时间复杂度:O(n^2)

IDE代码如下:

  1. package CCF_CSP;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class _20141201_100point {
  6.  
  7. public static void main(String[] args) {
  8. Scanner scanner = new Scanner(System.in);
  9. int n = scanner.nextInt();
  10. int[] num = new int[n];
  11.  
  12. for(int i=0;i<n-1;i++)
  13. {
  14. int count = 1; //该编号数字首次出现
  15. num[i]=scanner.nextInt();
  16. for(int j=0;j<i;j++)
  17. {
  18. if(num[j]==num[i]) //该编号再次出现
  19. {
  20. count++;
  21. }
  22. }
  23. System.out.print(count+" ");
  24. }
  25.  
  26. for(int i=n-1;i<n;i++) //用于输出最后一个数字,控制输出格式
  27. {
  28. int count = 1;
  29. num[i]=scanner.nextInt();
  30. for(int j=0;j<i;j++)
  31. {
  32. if(num[j]==num[i])
  33. {
  34. count++;
  35. }
  36. }
  37. System.out.print(count);
  38. }
  39. }
  40. }
  41.  

评论板

共有 5 条评论

  1. fruinly

    buy cialis usa pralatrexate decreases levels of taurine by unspecified interaction mechanism

  2. engarma

    Now you re probably wondering what exactly to take cialis for sale in usa

  3. Preliaf

    RANK and RANKL were slightly less compared to control mice, showing that the resorption process in Sp7 Cre; SMS1 f f; SMS2 mice was limited or retarded fincar finasteride online canada

  4. Preliaf

    can i buy cialis online Castrellon AB, GlГјck S

  5. sLlGTLon

    cialis levitra viagra It works by blocking the activity of certain electrical signals in the heart that can cause an irregular heartbeat

--------查看该分类下最新文章--------
^
新版博客正在完善中!域名:http://www.loveffc:8080,点击跳转,完全移植后将去除端口号。

Copyright © 2018 - 2021 FFC的小站 - 滇 ICP 备 18010780 号 - 1

- Powered by WordPress & AliYun · Theme by FFC -

- Environment by Windows & XAMPP · Designed by WebStorm & VSCode -

已运行:

访问量:498733