当前位置:网站首页>-象棋比赛-
-象棋比赛-
2022-08-09 23:46:00 【-JMY-】
题目描述
两位同学进行了n场的象棋比赛(3<=n<=9,且n是奇数),他们的参赛号分别是10和20,每场比赛都有一位胜出的同学(也就是不存在平局的情况),请问最终哪位同学取得了胜利?
输入
第1行有一个整数n,代表举办比赛的次数。
第2行有n个整数(这n个整数一定是10或者是20,代表获得胜利同学的参赛号)。
输出
输出获得胜利同学的参赛号。
样例输入
5 10 10 20 10 20
样例输出
10
参考代码:
#include<bits/stdc++.h>
using namespace std;
int n,a[15],t[25],maxn,k;
int main(){
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",a+i);
for(int i=0;i<n;i++){
t[a[i]]++;
if(t[a[i]]>maxn){
maxn=t[a[i]];
k=a[i];
}
}
printf("%d",k);
return 0;
}
边栏推荐
- dlopen failed: library "libtaml.so" not found
- 信息系统项目管理师核心考点(六十四)信息安全基础知识重要概念
- nfs配置
- 3.4 - 编译与解释 3.5 - 编译过程 3.8 - 文法
- Leetcode82. 删除排序链表中的重复元素 II
- 足不出户也能看星空
- 【「收藏」Oracle 数据库安装】
- Next.js获取路由参数及styled-jsx 的使用
- NotWritableError: The current user does not have write permissions when conda creates a new environment
- 算法---整数替换(Kotlin)
猜你喜欢

数字孪生智慧制造生产线项目实施方案,平台认知与概念

【问题解决】训练和验证准确率很高,但测试准确率很低

Digital wallets, red sea ecological rapid introduction of small programs can help capture device entry wisdom

漫谈缺陷管理的自动化实践方案

技术分享 | 接口自动化测试如何处理 Header cookie
![[C language] In-depth understanding of pointers and arrays (issue 4)](/img/22/ad31b47bb8cc1722121959efddefd5.png)
[C language] In-depth understanding of pointers and arrays (issue 4)

数字孪生电力系统,可视化应用实现科学调度的电子设备

selenium和驱动安装

手把手教你编写性能测试用例

2022中高级Android面试题汇总来助你通过面试
随机推荐
JVM Memory and Garbage Collection - 10. Direct Memory
线程的同步与互斥
Spark基础【RDD单Value类型转换算子】
算法---整数替换(Kotlin)
Why don't suggest you run in Docker Mysql?
渗透测试与攻防对抗——漏洞扫描&逻辑漏洞(Part1)
Golden Warehouse Database KingbaseGIS User Manual (6.6. Geometric Object Verification Function, 6.7. Spatial Reference System Function)
Digital wallets, red sea ecological rapid introduction of small programs can help capture device entry wisdom
Eureka protects itself
hql语言
JSP简介
c语言文件基本操作总结
Tensor flow 踩坑记
《MySQL入门很轻松》第4章:数据表中存放的数据类型
[Cloud native] Kubernetes orchestration tools
基于 LSTM 的分布式能源发电预测(Matlab代码实现)
足不出户也能看星空
网络协议05 -网络层
Linux安装Oracle和postgrepSQL数据库
CAS:183896-00-6 (Biotin-PEG3-C3-NH2) PEG衍生物