ACM-ICPC 2018 焦作赛区网络预赛 A. 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 \le T \le 100)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 1515.

Output

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

样例输入复制

2
Jessie
Justin

样例输出复制

Good guy!
Dare you say that again?

题目来源

ACM-ICPC 2018 焦作赛区网络预赛


题解:

题目的意思即是 现在有一个已经确定的字符串,然后输入字符串,与源字符串进行比较,若除大小写外无差别就输出“ Good guy!” ,否则输出“Dare you say that again?" 。

仅仅需要一个字符串的逐个位比较。


代码:

代码1

#include <cstdio>
#include <iostream>

using namespace std;

int main(){
    int a;
  	string c ="jessie",b;
  	scanf("%d",&a);
    for(;a;a--){
        cin>>b;
        int i=0,q=0;
        if(b.length()!=6){
        	printf("Dare you say that again?\n");
        	continue;
		}
        for(;i<7;i++){
        	if(b[i]==c[i] ||b[i]==c[i] - 32 ){
			    q++;
    		}else{
                    printf("Dare you say that again?\n");
                    break;
                }
		if(q==6){
			printf("Good guy!\n");
			}
		}	
	}
    return 0;
}

代码2

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;


int main(){
    int t;
    scanf("%d",&t);
    string s;
    string tt="jessie";
    while(t--){
        cin>>s;
        int flag=1;
        if(s.length()!=6){printf("Dare you say that again?\n");continue;}
        for(int i=0;i<s.length();i++){
            if(s[i]==tt[i]||s[i]==tt[i]-32)continue;
            else {flag=0;break;}
        }
        if(!flag)printf("Dare you say that again?\n");
        else printf("Good guy!\n");
    }
}

 

全部评论

相关推荐

11-24 00:11
已编辑
广东工业大学 算法工程师
避雷深圳&nbsp;&nbsp;yidao,试用期&nbsp;6&nbsp;个月。好嘛,试用期还没结束,就直接告诉你尽快找下一家吧,我谢谢您嘞
牛客75408465号:笑死,直属领导和 hr 口径都没统一,各自说了一些离谱的被裁理由,你们能不能认真一点呀,哈哈哈哈哈😅😅😅
点赞 评论 收藏
分享
10-25 12:05
已编辑
湖南科技大学 Java
若梦难了:我有你这简历,已经大厂乱杀了
点赞 评论 收藏
分享
11-05 07:29
贵州大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务