• 2016 Al-Baath University Training Camp Contest-1 B


    Description

    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
    题意:不区分大小写,还有i和e,d和b一样,给我们字符串,判断是不是在这个条件下相同
    解法:模拟
    #include<bits/stdc++.h>
    using namespace std;
    string s1,s2,s3,s4;
    int main()
    {
        int t;
        cin>>t;
        while(t--)
        {
            cin>>s1>>s2;
            s3="";
            s4="";
            for(int i=0;i<s1.length();i++)
            {
                if(s1[i]=='p'||s1[i]=='P')
                {
                    s3+='b';
                }
                else if(s1[i]=='i'||s1[i]=='I')
                {
                    s3+='e';
                }
                else
                {
                    s3+=tolower(s1[i]);
                }
            }
            for(int i=0;i<s2.length();i++)
            {
                if(s2[i]=='p'||s2[i]=='P'||s2[i]=='b'||s2[i]=='B')
                {
                    s4+='b';
                }
                else if(s2[i]=='i'||s2[i]=='I'||s2[i]=='E'||s2[i]=='e')
                {
                    s4+='e';
                }
                else
                {
                    s4+=tolower(s2[i]);
                }
            }
            if(s3==s4)
            {
                cout<<"Yes"<<endl;
            }
            else
            {
                cout<<"No"<<endl;
            }
           // cout<<s3<<endl;
        }
        return 0;
    }
    

      

  • 相关阅读:
    POJ 2891 Strange Way to Express Integers 中国剩余定理解法
    @Repository @Service 和@Autowired 的使用
    POJ 3070 Fibonacci
    无线局域网技术
    第一次ACM赛后总结及感悟
    Subsets II -- LeetCode
    [WebView学习之二]:使用Web Apps 支持不同分辨率屏
    微信公众平台开发新手教程(图文具体解释)
    翻译-In-Stream Big Data Processing 流式大数据处理
    Nginx + FastCgi + Spawn-fcgi + C 架构的server环境搭建
  • 原文地址:https://www.cnblogs.com/yinghualuowu/p/6040707.html
Copyright © 2020-2023  润新知