题目1057:众数
来源:互联网 发布:windows桌面经典壁纸 编辑:程序博客网 时间:2024/06/05 09:35
- 题目描述:
输入20个数,每个数都在1-10之间,求1-10中的众数(众数就是出现次数最多的数,如果存在一样多次数的众数,则输出权值较小的那一个)。
- 输入:
测试数据有多组,每组输入20个1-10之间的数。
- 输出:
对于每组输入,请输出1-10中的众数。
- 样例输入:
5 1 5 10 3 5 3 4 8 6 8 3 6 5 10 7 10 2 6 2
- 样例输出:
5
#include<iostream>#include<stdio.h>#include<string.h>using std::cin;using std::cout; int lmd(int a,int b){ if(b==0) return a; else return lmd(b,a%b);}int main(){ int hash[11]; int c=0; int n; memset(hash,0,sizeof(hash)); while(cin>>n) { hash[n]+=1; c++; if(c<20) continue; int max=1; for(int c=2;c<11;c++) if(hash[c]>hash[max]) max=c; cout<<max<<"\n"; c=0; memset(hash,0,sizeof(hash)); }}
- 题目1057:众数
- 题目1057:众数
- 题目1057:众数
- 题目1057:众数
- 题目1057:众数
- 题目1056:最大公约数 题目1057:众数
- 九度OJ—题目1057:众数
- 九度 Online Judge 算法 刷题 题目1057:众数
- NYOJ 题目95 众数问题
- NYOJ---题目95众数问题
- 九度 题目1057:众数 2011年 哈尔滨工业大学 计算机 研究生 机试真题
- 九度1057 众数
- 九度 1057 众数
- 九度-1057-众数
- 众数
- 众数
- 众数
- 众数
- CSS3之过渡Transition
- 如何定位占用oracle数据库cpu过高的sql
- ORACLE导入导出
- ExtJS 4 grid 带参数 查询 分页 store beforeload 解决办法
- 正则表达式——毕向东java
- 题目1057:众数
- 字符串逆序的算法汇总
- 头文件string与string.h的区别
- Switch (ASCII)分离不同单词
- Codeforces Beta Round #94 (Div. 2 Only) B. Students and Shoelaces
- hdu 1021Fibonacci Again
- 题目1061:成绩排序
- Android工程运行 ADB server didn't ACK * failed to start daemon *错误
- 亚马逊2013的一道在线笔试题