Problem A: 零起点学算法91——找出一个数组中出现次数最多的那个元素
#include<stdio.h>
int main()
{
int n,a[],b[]={};
while(scanf("%d",&n)!=EOF)
{
for(int i=;i<n;i++)
{
scanf("%d",&a[i]);
} for(int i=;i<n;i++)
{
for(int j=i+;j<n;j++)
{
if(a[i]==a[j])
{
b[i]++;
}
}
} int m=b[];
for(int i=;i<n;i++)
{
if(b[i]>m)
m=b[i];
} for(int i=;i<n;i++)
{
if(b[i]==m)
{
printf("%d\n",a[i]);
}
}
}
return ;
}
Problem A: 零起点学算法91——找出一个数组中出现次数最多的那个元素的更多相关文章
- Problem B: 零起点学算法81——找出数组中最大元素的位置(下标值
#include<stdio.h> int main(void) { ],i,max; while(scanf("%d",&n)!=EOF) { ;i<n ...
- [PY3]——找出一个序列中出现次数最多的元素/collections.Counter 类的用法
问题 怎样找出一个序列中出现次数最多的元素呢? 解决方案 collections.Counter 类就是专门为这类问题而设计的, 它甚至有一个有用的 most_common() 方法直接给了你答案 c ...
- 笔试题&面试题:找出一个数组中第m小的值并输出
题目:找出一个数组中第m小的值并输出. 代码: #include <stdio.h> int findm_min(int a[], int n, int m) //n代表数组长度,m代表找 ...
- 找出整数数组中出现次数超过数组长度一半的元素(Java)
Question:数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字 package com.study.zhipengs.test; import java.util.Arrays; im ...
- Problem H: 零起点学算法109——单数变复数
#include <stdio.h> #include<string.h> int main(void) { int n; ]; scanf("%d",&a ...
- Problem G: 零起点学算法106——首字母变大写
#include<stdio.h> #include<string.h> int main(void) { ]; int i,k; while(gets(a)!=NULL) { ...
- Problem D: 零起点学算法95——弓型矩阵
#include<stdio.h> #include<string.h> int main() { ][]; while(scanf("%d%d",& ...
- Problem F: 零起点学算法42——多组测试数据输出II
#include<stdio.h> int main() { ; while(scanf("%d%d%d",&a,&b,&c)!=EOF) { ...
- Problem E: 零起点学算法34——3n+1问题
#include<stdio.h> #include<math.h> int main() { int n; n<=pow(,); ; scanf("%d&qu ...
随机推荐
- vim 以16进制进行文件编辑
用 vim中二进制文件的编辑是先通过外部程序xxd来把文件dump成其二进制的文本形式,然后就可以按通常的编辑方式对文件进行编辑,编辑完成后再用xxd 转化为原来的形式即可. 可分如下几步进行: (1 ...
- css 背景透明,文字不透明
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- Ubuntu 14.04 安装gstreamer0.10-ffmpeg
sudo apt-add-repository ppa:mc3man/trusty-media sudo apt-get update sudo apt-get install -y gstreame ...
- java===java基础学习(14)---封装
package dog; public class Demo4 { public static void main(String []args) { Worker w1= new Worker(&qu ...
- Makefile 跟着走快点
引言 - 从"HelloWorld"开始 Makefile 是Linux C 程序开发最重要的基本功. 代表着整个项目编译和最终生成过程.本文重点是带大家了解真实项目中那些简易的 ...
- opencv 图像转换
#include <cv.h> #include <highgui.h> int main() { CvPoint2D32f srcTri[], dstTri[]; CvMat ...
- Fel表达式使用过程中需要注意的问题
精度问题: 我们知道java中直接使用float和double参与的计算都可能会产生精度问题,比如0.1+0.3.1.0-0.9 等.所以一般财务系统,都会使用BigDecimal进行加减乘除. 在调 ...
- windows下github 出现Permission denied (publickey)
github教科书传送门:http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 再学习到 ...
- 《深入浅出MyBatis技术原理与实战》——7. 插件
在第6章讨论了四大运行对象的运行过程,在Configuration对象的创建方法里我们看到了MyBatis用责任链去封装它们. 7.1 插件接口 在MyBatis中使用插件,我们必须使用接口Inter ...
- python 单例模式4中实现方法
python实现单例模式的方法: 1. 使用模块 python的模块在第一次导入时会生成.pyc文件,当第二次导入时就会直接加载.pyc文件,而不会再次执行模块代码. 只需将其单独放在一个模块里,并创 ...