美文网首页
2018暑期SICNU-ACM组集训报告(8)

2018暑期SICNU-ACM组集训报告(8)

作者: 姬空魂 | 来源:发表于2018-08-13 11:16 被阅读0次

    题目:
    Zero or One
    File: zero.[c|cpp|java]
    Everyone probably knows the game Zero or One (in some regions in Brazil also known as Two or
    One), used to determine a winner among three or more players. For those unfamiliar, the game works
    as follows. Each player chooses a value between zero or one; prompted by a command (usually one of
    the contestants announces “Zero or... One!”), all participants show the value chosen using a hand: if
    the value chosen is one, the contestant shows a hand with an extended index finger; if the value chosen
    is zero, the contestant shows a hand with all fingers closed. The winner is the one who has chosen
    a value different from all others. If there is no player with a value different from all others (e.g. all
    players choose zero, or some players choose zero and some players choose one), there is no winner.
    Alice, Bob and Clara are great friends and play Zerinho all the time: to determine who will buy
    popcorn during the movie session, who will enter the swimming pool first, etc.. They play so much
    that they decided make a plugin to play Zerinho on Facebook. But since the don’t know how to
    program computers, they divided the tasks among friends who do know, including you.
    Given the three values chosen by Alice, Bob and Clara, each value zero or one, write a program
    that determines if there is a winner, and in that case determines who is the winner.
    Input
    The input contains a single line, with three integers A, B and C ,indicating respectively the values
    chosen by Alice, Beto and Clara.
    Output
    Your program must output a single line, containing a single character. If Alice is the winner the
    character must be ‘A’, if Beto is the winner the character must be ‘B’, if Clara is the winner the
    character must be ‘C’, and if there is no winner the character must be ‘*’ (asterisc).
    Restrictions
    • A, B, C ∈ {0, 1}
    Examples
    Input
    1 1 0
    Output
    C
    Input
    0 0 0
    Output

    Input
    1 0 0
    Output
    A

    题意:输入三个1或0,判断哪个数据和另外两个不一样并输出ABC代表位置,如果三数据都相同输出*

    AC代码:

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a,b,c;
        cin>>a>>b>>c;
        if(a==b&&b==c)
        {
            cout<<"*";
        }
        if(a==b&&b!=c){
            cout<<"C";
        }
        if(b==c&&a!=b){
            cout<<"A";
        }
        if(a==c&&b!=c){
            cout<<"B";
        }
        return 0;
    }
    

    相关文章

      网友评论

          本文标题:2018暑期SICNU-ACM组集训报告(8)

          本文链接:https://www.haomeiwen.com/subject/xwvybftx.html