zoukankan      html  css  js  c++  java
  • 省赛热身赛之Kagome Kagome

    原题:

    Description

    Kagome kagome, kago no naka no tori wa
    Itsu itsu deyaru? Yoake no ban ni
    Tsuru to kame to subetta.
    Ushiro no shoumen daare?
    
    Translation:
    Kagome kagome, the bird in the cage,
    when will you come out?
    In the evening of the dawn,
    the crane and turtle slipped.
    Who stands right behind you now?
    

    Kagome Kagome is a Japanese children's game. One child is chosen as the oni (literally demon or ogre, but similar to the concept of "it" in tag) and sits blindfolded (or with their eyes covered). The other children join hands and walk in circles around the oni while singing the song for the game. When the song stops, the oni speaks aloud the name of the person behind him, and if he is correct, the person behind will exchange places with the oni.

    Higurashi Tewi is playing Kagome Kagome with her n (n is even) friends as the oni now. She peeps to know who is right in front of her. Knowing the order of the children in circle and assuming that they keep distance evenly, it's easy to derive who is right behind her.

    Input

    There are multiple test cases. The first line of input is an integer T ≈ 100 indicating the number of test cases. 

    The first line of each test case starts with an even number 1 ≤ n ≤ 100, followed by the name of the child who is right in front of Higurashi Tewi. The second line contains exactly n different names, listed in counterclockwise order. Name is an alphanumeric string whose length never exceeds 20. It's guaranteed that the child in front of Higurashi Tewi is always contained in the list exactly once.

    Output

    For each test case, output the name of the child who is right behind Higurashi Tewi.

    Sample Input

    3
    2 Alice
    Alice Bob
    4 inu
    inu neko usagi kizune
    4 cat
    dog cat rabbit fox
    

    Sample Output

    Bob
    usagi
    fox
    分析:
    不知道为什么用scanf和printf会报错??????????????????
    原码:
    #include<iostream>
    #include<string.h>
    #include<stdio.h>
    using namespace std;
    int main()
    {
        int t, n, i, a;
        string name, str[110];
        scanf("%d",&t);
        while (t--)
        {
            scanf("%d",&n);
            cin>>name;//不知道为什么用scanf会报错,以后就用cin了!
            a = 0;
            for (i=0; i<n; i++)
                cin >> str[i];
            for (i=0; i<n; i++)
                if (str[i] == name)
                    break;
            a=(i+n/2)%n;
            cout<<str[a]<<endl;//不知道为什么用printf会报错,以后就用cout了!
        }
        return 0;
    }
    
     
     
  • 相关阅读:
    OGRE 3D 1.7 Beginner‘s Guide中文版 第一章
    一个人的成功取决于晚上的8点至10点--经典语录必读
    学历代表过去、能力代表现在、学习力代表未来
    理财达人五步走
    Ogre场景、节点、摄像机通过自动、鼠标、键盘控制移动
    QT按钮背景颜色设置及文字显示位置设置
    Qt一个工程调用另一个工程的类成员变量
    C++搜索字符串中的汉字
    Q窗口操作函数(窗口最大化,全屏,隐藏最大化最小化按钮)
    PAT(Advance Level)Practice1001
  • 原文地址:https://www.cnblogs.com/xinyuyuanm/p/2980773.html
Copyright © 2011-2022 走看看