当前位置:网站首页>Hero King C language
Hero King C language
2022-04-21 18:18:00 【Big dish color】
Hero King
The League of heroes finals are in full swing , Blind monk 、 Sister Dao 、 Wine barrel 、 Qinggang shadow and other heroes all appeared , When a hero is selected, the system automatically registers its serial number , The hero with the most appearances becomes the king of appearances . The set of appearances given the hero's serial number T, for example ,T={2,4,4,4,6,7}. Its appearance king is 4 Hero No , The number of appearances is 3. For a given by n An appearance set composed of sequence numbers T, Calculate the king's serial number and the number of appearances . If there are multiple kings , Please output the one with the smallest serial number .
Input format :
Number of input data 1 OK, it's a hero episode T Number of serial numbers in n(n<1000); Second line input n Number of Heroes ( No more than 5 A natural number of digits ).
Output format :
The second of the output data 1 The line gives the sequence number of the appearance King , The first 2 OK, it's the number of appearances .
sample input :
Here's a set of inputs . for example :
6
2 4 4 4 6 7
sample output :
Here is the corresponding output . for example :
4
3
Code :
#include<stdio.h>
int main()
{
int n,i,j=0,m,t=0,a[1001]={
0};
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&m);
a[m]++;
}
for(i=0;i<1000;i++)
if(a[i]!=0)
if(a[i]>t)
{
t=a[i];
j=i;
}
printf("%d\n",j);
printf("%d",a[j]);
return 0;
}
版权声明
本文为[Big dish color]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211816371925.html
边栏推荐
猜你喜欢

靶机渗透练习69-DC1

redis启动服务和连接客户端

Don't look for it. This is the clearest article on microservices so far! No one

为什么switch里的case没有break不行

Target penetration exercise 78 Thoth Tech

人员不足、供应链断裂,危机之下制造业该如何自救?

ansible简单使用示例

Porting openharmony and adding WiFi driver

靶机渗透练习79-Venom

Advanced formula 46 of C language: function and macro analysis
随机推荐
教你轻松解决CSRF跨站请求伪造攻击
单例模式你不得不知道的底层原理
Target penetration exercise 78 Thoth Tech
靶机渗透练习77-DC9
Mycat水平分表(全局表)
Interface test framework practice (II) | interface request assertion
Golang中Json的序列化和反序列化怎么使用
Tooltip component: judge whether to display tooltip according to whether the content overflows
Target penetration exercise 77-dc9
不同研发协作模式在云效中的应用
[intensive reading of Thesis] perception based seam cutting for image stitching
还剩下载次数,可留链接+邮箱
IoT平台如何实现业务配置中心
华为18级大牛整理总结:微服务设计和分布式服务框架原理实践文档
[untitled]
安装网卡驱动失败(已解决)
启牛app证券账户安全吗?谁在这开了?
redis启动服务和连接客户端
靶机渗透练习72-DC4
集合之ArrayList