A2011 Magic Mirror

简介: A2011 Magic Mirror

文章目录

一、A2011 Magic Mirror

总结


一、A2011 Magic Mirror

本题链接:A2011 Magic Mirror


题目:

Jessie has a magic mirror.


Every morning she will ask the mirror: ‘Mirror mirror tell me, who is the most beautiful girl in the world?’ If the mirror says her name, she will praise the mirror: ‘Good guy!’, but if the mirror says the name of another person, she will assail the mirror: ‘Dare you say that again?’


Today Jessie asks the mirror the same question above, and you are given a series of mirror’s answers. For each answer, please output Jessie’s response. You can assume that the uppercase or lowercase letters appearing anywhere in the name will have no influence on the answer. For example, ‘Jessie’ and ‘jessie’ represent the same person.


Input

The first line contains an integer T(1≤T≤100), which is the number of test cases.


Each test case contains one line with a single-word name, which contains only English letters. The length of each name is no more than 15.


Output

For each test case, output one line containing the answer.


样例输入

2

Jessie

Justin


样例输出

Good guy!

Dare you say that again?


本博客给出本题截图:

image.png

image.png

AC代码

#include <cstdio>
#include <cstring>
using namespace std;
const int N = 20;
char s[N];
int main()
{
    int n;
    scanf("%d", &n);
    while (n -- )
    {
        scanf("%s", s);
        for (int i = 0; s[i]; i ++ )
            if (s[i] >= 'A' && s[i] <= 'Z')
                s[i] = s[i] - 'A' + 'a';
        if (strcmp(s, "jessie")) puts("Dare you say that again?");
        else puts("Good guy!");
    }
    return 0;
}

总结

这步的操作是让s中所有的字母都变成小写字母,方便我们进行比较

        for (int i = 0; s[i]; i ++ )
            if (s[i] >= 'A' && s[i] <= 'Z')
                s[i] = s[i] - 'A' + 'a';


目录
相关文章
|
9月前
MTK在编译10A的target时报错:make: *** [mmi_feature_check]
MTK在编译10A的target时报错:make: *** [mmi_feature_check]
39 0
|
9月前
|
Java Maven
Cannot access repo1 (http://repo1.maven.org/maven2) in offline mode and the
Cannot access repo1 (http://repo1.maven.org/maven2) in offline mode and the
181 0
|
9月前
|
Java
No tag [else] defined in tag library imported with prefix [c]] with root cause
No tag [else] defined in tag library imported with prefix [c]] with root cause 错误处理
62 0
LeetCode 67. Add Binary
给定两个二进制字符串,返回它们的总和(也是二进制字符串)。 输入字符串都是非空的,只包含字符1或0。
88 0
LeetCode 67. Add Binary
编译mate-control-center:error: required directory ./help does not exist
编译mate-control-center:error: required directory ./help does not exist
112 0
add file in debian/source/include-binaries if you want to store the modified binary in the debian
add file in debian/source/include-binaries if you want to store the modified binary in the debian
414 0
The 'manifest_version' key must be present and set to 2 (without quotes)
The 'manifest_version' key must be present and set to 2 (without quotes)
96 0
|
Java Linux
LINUX编译OPENJDK:The tested number of bits in the target (0) differs from the number of bits expected
LINUX编译OPENJDK:The tested number of bits in the target (0) differs from the number of bits expected
236 0
|
Perl
[!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `cocoapods`. Y...
[!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `cocoapods`. Y...
1970 0
|
iOS开发
漂亮得不像触控板,全新 Magic Trackpad 2
上周末突然心血来潮给mac买了外设。笔记本支架、magic trakpad 2、magic mouse、无线机械键盘。由于我没有买过macbook的转接头,所以我的配件都是无线的。
2049 0