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';


目录
相关文章
|
7月前
|
安全 网络协议 Linux
yum出现Loaded plugins: fastestmirror, security Loading mirror speeds from cached hostfile解决方法
yum出现Loaded plugins: fastestmirror, security Loading mirror speeds from cached hostfile解决方法
768 3
|
8月前
|
Java 定位技术 Android开发
安装apk显示 requires unavailable shared library com.xxx
安装apk显示 requires unavailable shared library com.xxx
100 0
|
8月前
|
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
170 0
|
数据可视化 Java Shell
JupyterNotebook‘s Magic
JupyterNotebook‘s Magic
92 1
MAC编译lame ld: symbol(s) not found for architecture x86_64/_lame_init_old“, referenced from
MAC编译lame ld: symbol(s) not found for architecture x86_64/_lame_init_old“, referenced from
293 0
relocation R_X86_64_PC32 against symbol can not be used when making a shared object recompile with
relocation R_X86_64_PC32 against symbol can not be used when making a shared object recompile with
747 0
AS 3.6 之前和之后No cached version available for offline mode 解决方法
AS 3.6 之前和之后No cached version available for offline mode 解决方法
156 0
AS 3.6 之前和之后No cached version available for offline mode 解决方法
|
缓存
Error:Could not download ecj.jar : No cached version available for offline mode
Error:Could not download ecj.jar : No cached version available for offline mode
269 0
Error:Could not download ecj.jar : No cached version available for offline mode
libgsm.a relocation R_X86_64_PC32 can not be used when making a shared object; recompile with -fPIC
libgsm.a relocation R_X86_64_PC32 can not be used when making a shared object; recompile with -fPIC
245 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
231 0