A. Football
来源:互联网 发布:淘宝发货地在哪里设置 编辑:程序博客网 时间:2024/05/24 03:22
A. Football
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
One day Vasya decided to have a look at the results of Berland 1910 Football Championship’s finals. Unfortunately he didn’t find the overall score of the match; however, he got hold of a profound description of the match’s process. On the whole there are n lines in that description each of which described one goal. Every goal was marked with the name of the team that had scored it. Help Vasya, learn the name of the team that won the finals. It is guaranteed that the match did not end in a tie.
Input
The first line contains an integer n (1 ≤ n ≤ 100) — the number of lines in the description. Then follow n lines — for each goal the names of the teams that scored it. The names are non-empty lines consisting of uppercase Latin letters whose lengths do not exceed 10 symbols. It is guaranteed that the match did not end in a tie and the description contains no more than two different teams.
Output
Print the name of the winning team. We remind you that in football the team that scores more goals is considered the winner.
Examples
Input
1
ABC
Output
ABC
Input
5
A
ABA
ABA
A
A
Output
A
#include<stdio.h>int main(){ int n; char a[12]; char s[101][12]; int b[101]; memset(b,0,sizeof(b)); while(~scanf("%d",&n)) { int i=0,k=0,j; int max=0,temp; for(j=0; j<n; j++) { scanf("%s",a); for(i=0; i<k; i++) { if(strcmp(s[i],a)==0) { b[i]++; } }///比较输入的字母有多少 if(i==k) { strcpy(s[i],a); k++; b[i]++; }///用于把录入的字母录入在数组中用于比较 } for(i=0; i<k; i++) { if(max<b[i]) { max=b[i]; temp=i; } }///比较输入的字符串的多少然后输出 printf("%s\n",s[temp]); } return 0;}
总结:是一道简单的字符串比较题目,不需要一次性输入多组数据,可以每输入一组数据然后与下一组进行比较 这样可以少用for循环 因此可以减少时间。用字符串的函数将输入的字符串存储便于比较。
- A. Football
- A. Football
- A. Football
- CF:96A.Football
- CF:43A. Football
- CodeForces-96A-Football
- 96A - Football
- A. Vasya and Football
- A Vasya and Football
- 96A - Football
- Codeforces 43 A. Football
- A. Vasya and Football
- CF 96A Football
- 【CodeForces】A. Football
- A. World Football Cup
- CodeForces 96A Football
- codeforces 43A Football
- codeforces 96A Football
- live555学习笔记1-引子
- codves 笨小猴 1053
- 2017-2-16
- 第二讲、Jmeter常用组件介绍
- Spring常用注解汇总
- A. Football
- Android Studio 真机测试中遇到"No target device found"
- 机器学习中的数据清洗与特征处理综述
- 构建器的初始化
- live555学习笔记2-基础类
- 绪论
- 简单说一说数据结构——链表
- 监听器的实现方法
- 4591: [Shoi2015]超能粒子炮·改