Bonapity Gym - 101028B

版权声明:文章全是安利转载啦,自娱自乐喽, 可以随意操作哟! https://blog.csdn.net/ggqinglfu/article/details/82191636

A group of junior programmers are attending an advanced programming camp, where they learn very difficult algorithms and programming techniques! Near the center in which the camp is held, is a professional bakery which makes tasty pastries and pizza. It is called 'Bonabity'... or 'Ponapety'... or 'Ponabity'... Actually no one knows how to spell this name in English, even the bakery owner doesn't, and the legends say that Arabs always confuse between 'b' and 'p', and also between 'i' and 'e', so 'b' for them is just the same as 'p', and 'i' for them is just the same as 'e', they also don't care about letters' cases (uppercase and lowercase for a certain letter are similar). For example, the words 'Ponabity' and 'bonabety' are considered the same. You are given two words including only upper case and lower case English letters, and you have to determine whether the two words are similar in Arabic.

Input

The input consists of several test cases. The first line of the input contains a single integer T, the number of the test cases. Each of the following T lines represents a test case and contains two space-separated strings (each one consists of only upper case and lower case English letters and its length will not exceed 100 characters)

 Output

For each test case print a single line: 'Yes' if the words are similar in Arabic and 'No' otherwise.

Example

Input

4
Ponabity bonabety
barbie barpee
abcabc apcap
abc apcd

Output

Yes
Yes
No
No

1、字符串的处理看起来很简单的, 统一 为大写字母。

2、strcmp 挺好用的, 尽管可能比较慢。

3、这题看似很难, 其实虚有其表。

 噢:代码是队友写的 , 转载声明 链接地址

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#define INF 0x3f3f3f3f
using namespace std;

void f(char *s)      //统一大小写, 转化P、I;
{
    for( int i = 0; i < strlen(s); i++)
    {
        if(s[i] >= 97 && s[i] <= 123)
            s[i] -= 32;
        if(s[i] == 'P')
            s[i] = 'B';
        else if(s[i] == 'I')
            s[i] = 'E';
    }
}

int main()
{
    ios::sync_with_stdio(0);
    int t;
    char s1[100], s2[100];
    cin >> t;
    while(t--)
    {
        cin >> s1 >> s2;
        f(s1);
        f(s2);
        if(!strcmp(s1, s2))
            cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/ggqinglfu/article/details/82191636