找出现次数最多的数-Ignatius and the Princess IV
来源:互联网 发布:程序员网上接项目 编辑:程序博客网 时间:2024/06/06 08:28
#include<iostream>#include<cstring>using namespace std;int main(){ while(1) { int i,b,max=1; long long n; cin>>n; int a[n]; memset(a,0,sizeof(a)); for(i=1; i<=n; i++) { cin>>b; a[b]++; if(b>max) max=b; } b=a[1]; for(i=2; i<=max; i++) { if(a[i]>b) b=a[i]; } for(i=1; i<=max; i++) { if(a[i]==b) cout<<i<<endl; } } return 0;}
用数组做时提示runtime error,可能是越界了。
0 0
- 找出现次数最多的数-Ignatius and the Princess IV
- HDU1029:Ignatius and the Princess IV -DP求一列数中出现次数最多的数的次数
- hdu1029 Ignatius and the Princess IV(DP求数列中出现次数过半的数)
- HDU-OJ-1029 Ignatius and the Princess IV-出现至少(N+1)/2次的数
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- cocos2dx-3.0(13)------SpriteBatchNode与SpriteFrameCache加快渲染
- 大学生投注“互联网+”营销QQ推动传统企业转型
- _DataStructure_C_Impl:广义表的扩展线性链表存储
- 查看MySQL编码格式指令
- js 判断输入都年份是不是闰年
- 找出现次数最多的数-Ignatius and the Princess IV
- HDU-OJ-1017 A Mathematical Curiosity-整数对
- URAL 1319. Hotel
- 安卓实现登陆
- mac 下面如何安装brew
- 基督徒的工作观
- hpuoj 1697 找句子
- Android 蓝牙4.0 Bluetooth BLE 写数据(修改BLE设备的属性)
- 关于 Java 程序员的一些入门级面试题