校友会

ZZULIOJ 1123: 最佳校友

喜夏-厌秋 提交于 2020-02-15 08:36:33
1123: 最佳校友 题目描述 北京校友会每年举办两次,所有校友都有校友编号,每次到会的校友都在签到簿上写下自己的编号和姓名,在校友会成立5周年的聚会上将颁发“最佳校友奖”,该奖项颁发给到会次数最多的校友。现在请你编写程序,找出这个奖项的得主。若有多个校友并列第一,则均可获奖。 输入 输入若干个整数,表示签到簿上的校友编号,所有编号均为0~99的整数,以一个负数作为输入结束的标志。 输出 输出出现次数最多的编号。若获奖选手有多个,则按 从小到大 的顺序输出选手编号,用空格隔开。 样例输入 4 5 3 1 3 4 2 7 -1 样例输出 3 4 (C语言) # include <stdio.h> int main ( ) { int a [ 100 ] = { 0 } , n , i ; while ( scanf ( "%d" , & n ) && n >= 0 ) //输入若干整数,并以负数结束 { a [ n ] ++ ; //编号n直接当作数组a的第n-1个元素,直接统计同一编号出现的次数 } int max = a [ 0 ] ; for ( i = 1 ; i < 100 ; i ++ ) { if ( a [ i ] > max ) { max = a [ i ] ; } } //打擂台得出出现次数最多的编号 for ( i = 0 ; i < 100 ; i ++ )

# PAT(甲级)2019年春季考试 7-2 Anniversary (25 分)

匿名 (未验证) 提交于 2019-12-02 23:59:01
Zhejiang University is about to celebrate her 122th anniversary in 2019. To prepare for the celebration, the alumni association (校友会) has gathered the ID’s of all her alumni. Now your job is to write a program to count the number of alumni among all the people who come to the celebration. Input Specification: Each input file contains one test case. For each case, the first part is about the information of all the alumni. Given in the first line is a positive integer N N N (≤105). Then N N N lines follow, each contains an ID number of an alumnus. An ID number is a string of 18 digits or the