• CF43A Football


    题意翻译

    题目大意

    两只足球队比赛,现给你进球情况,问哪支队伍赢了。

    第一行一个整数nn (1leq nleq 1001n100 ),表示有nn 次进球,接下来nn 行,每行一个长度不超过1010 ,只由大写字母组成的字符串,表示一个进球的球队名,保证只有两个球队。

    输出一个字符串表示胜利球队的球队名,不会平局。

    Translated by Khassar

    题目描述

    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 nn 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.

    输入输出格式

    输入格式:

     

    The first line contains an integer nn ( 1<=n<=1001<=n<=100 ) — the number of lines in the description. Then follow nn 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.

     

    输出格式:

     

    Print the name of the winning team. We remind you that in football the team that scores more goals is considered the winner.

     

    输入输出样例

    输入样例#1: 复制
    1
    ABC
    
    输出样例#1: 复制
    ABC
    
    输入样例#2: 复制
    5
    A
    ABA
    ABA
    A
    A
    
    输出样例#2: 复制
    A

    思路:因为只有两队,所以只统计一个队伍的成绩即可,总分减去该队伍的成绩就是另一个队伍的成绩。

    #include<cstdio>
    #include<cstring>
    #include<iostream>
    using namespace std;
    int n;
    int grade[2];
    string str,name[2];
    int main(){
        scanf("%d",&n);
        cin>>name[0];grade[0]++;
        for(int i=1;i<=n-1;i++) {
            cin>>str;
            if(str!=name[0])    name[1]=str;
            else grade[0]++;
        }
        if(grade[0]>n-grade[0])    cout<<name[0]; 
        else    cout<<name[1];
    }
    细雨斜风作晓寒。淡烟疏柳媚晴滩。入淮清洛渐漫漫。 雪沫乳花浮午盏,蓼茸蒿笋试春盘。人间有味是清欢。
  • 相关阅读:
    【JavaScript】Object 实例属性
    【JavaScript】Object 构造函数和属性
    【JavaScript】Object 静态方法(三)
    PTA 乙级 1051 复数乘法 (15分) Python
    PTA 乙级 1050 螺旋矩阵 (25分) C++
    PTA 乙级 1049 数列的片段和 (20分) C/C++ (更新OJ导致测试点2无法通过,已解决)
    对象的深拷贝和浅拷贝和拷贝方法
    linux(腾讯云服务器)上安装mysql数据库
    SQLyog远程连接mysql数据库
    linux中搭建tomcat环境
  • 原文地址:https://www.cnblogs.com/cangT-Tlan/p/8442500.html
Copyright © 2020-2023  润新知