zoukankan      html  css  js  c++  java
  • 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];
    }
    细雨斜风作晓寒。淡烟疏柳媚晴滩。入淮清洛渐漫漫。 雪沫乳花浮午盏,蓼茸蒿笋试春盘。人间有味是清欢。
  • 相关阅读:
    无线网破解软件|一键式破解无线网|BT17软件包下载[笔记本+软件就行]
    Boost环境配置及遇到的问题解决方案
    HDU 4255 A Famous Grid
    uva 10306
    系统学习Linux的11点建议
    linux shell except tcl login ssh Automatic interaction
    常用网址记录
    am335x Qt SocketCAN Demo hacking
    a demo for how to use QThread
    OK335xS CAN device register and deiver match hacking
  • 原文地址:https://www.cnblogs.com/cangT-Tlan/p/8442500.html
Copyright © 2011-2022 走看看