当前位置:网站首页>7-7 solving mode problems
7-7 solving mode problems
2022-06-24 23:31:00 【White -】
7-7 Solve the mode problem
Given to contain n Multiple sets of elements S, Each element in S The number of occurrences in is called the multiplicity of the element . Multiple sets S The element with the largest multiplicity is called mode . for example ,S={1,2,2,2,3,5}. Multiple sets S What is the mode 2, Its multiplicity is 3. For a given by n A multiple set of natural numbers S, Calculation S Mode and multiplicity of . If there are multiple modes , Please output the smallest one .
Input format :
Number of input data 1 Rows are multiple sets S The number of elements in n(n<1000); Second line input n Up to 5 A natural number of digits .
14
1 2 2 2 3 3 5 6 6 5 6 2 7 6
Output format :
The second of the output data 1 OK, give me a few , The first 2 A row is a multiplicity .
2 4
Code :
#include <stdio.h>
#include <stdlib.h>
int n;
int a[10100];
int temp[10100];
int min=9999;
int mintime=0;
int main()
{
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
for(int i=0;i<n;i++)
{
int x=a[i];
temp[x]++;
if(temp[x]>mintime)
{
mintime=temp[x];
min=x;
}
else if(temp[x]==mintime&&x<min)
min=x;
}
printf("%d %d",min,mintime);
return 0;
}
202206222116 3、 ... and
边栏推荐
- Laravel pagoda security configuration
- 点的螺旋距离
- Record the range of data that MySQL update will lock
- 22map introduction and API
- [JS] - [string - application] - learning notes
- 7-5 最大子矩阵和问题
- 六大行数据治理现状盘点:治理架构、数据标准与数据中台(2022.04)
- golang convert json string to map
- jar中没有主清单属性
- R language dplyr package group_ By function and summarize_ The at function calculates the dataframe to calculate the number of counts and the mean value of different groups (summary data by category v
猜你喜欢

Hyperledger Fabric 2. X dynamic update smart contract

Installation and deployment of ganglia

Laravel pagoda security configuration

【js】-【字符串-应用】- 学习笔记

What good smart home brands in China support homekit?

斐波那契

点的螺旋距离

Design and practice of vivo server monitoring architecture

Selective sort method

Continuous soul torture from two MySQL indexes of interviewers
随机推荐
选择类排序法
Collation of Digital IC design experience (II)
InnoDB, the storage engine of MySQL Architecture Principle_ Redo log and binlog
R language uses the aggregate function of epidisplay package to split numerical variables into different subsets based on factor variables, calculate the summary statistics of each subset, and customi
378. Knight placement
[JS] - [tree] - learning notes
六大行数据治理现状盘点:治理架构、数据标准与数据中台(2022.04)
7-6 铺设油井管道
2021-2022 China's financial digitalization "new" insight Industry Research Report
sql -CONVERT函数
R语言使用MatchIt包进行倾向性匹配分析、使用match.data函数构建匹配后的样本集合、对匹配后的样本的不同分组对应的目标变量的均值进行Welch双样本t检验分析、双独立样本t检验
golang map clear
Adding, deleting, querying and modifying MySQL tables
还在用 SimpleDateFormat 做时间格式化?小心项目崩掉
Fibonacci
基于三维GIS开发的水电工程建设方案
7-8 循环日程安排问题
MySQL semi sync replication
R语言使用epiDisplay包的aggregate函数将数值变量基于因子变量拆分为不同的子集,计算每个子集的汇总统计信息、自定义FUN参数为多个统计量函数名称的列表计算多个统计量
第六章 网络学习相关技巧5(超参数验证)