当前位置:网站首页>-象棋比赛-
-象棋比赛-
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;
}
边栏推荐
猜你喜欢
深入理解Aarch64内存管理
重估HR SaaS:一体化后的新三年
足不出户也能看星空
源码编译安装LAMP和LNMP
deepstream学习笔记(三):deepstream-imagedata-multistream解析与接入适配yolov5模型测试
365天挑战LeetCode1000题——Day 052 逐步求和得到正数的最小值 贪心
selenium和驱动安装
Creo5.0 introductory tutorial free material
从TRPO到PPO(理论分析与数学证明)
[C language] In-depth understanding of pointers and arrays (issue 4)
随机推荐
LSTM-based distributed energy generation prediction (Matlab code implementation)
WPF DataGrid 使用数据模板
When knowledge and action are one
拒绝“重复造轮子”,百度EasyDL让你玩转AI定制开发
arm-4-裸板开发
【「收藏」Oracle 数据库安装】
Creo5.0 introductory tutorial free material
nfs配置
Copper's emotion
使用C语言实现静态链表
移动终端数据业务高安全通信方案研究
2022金九银十工作潮,怎么样才能成功跳槽面试拿到高薪呢?
微服务【同步和异步通讯详解】第6章
天猫全网商品详情封装接口
ETCD快速入门-02 ETCD安装
Leetcode81. 搜索旋转排序数组 II
生成树和交换的总结
redis distributed lock code example
NTU General Database-Gbase-8a-Learning-04-Deploying Distributed Clusters
3.4 - 编译与解释 3.5 - 编译过程 3.8 - 文法