zoukankan      html  css  js  c++  java
  • 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;
    }
    

      

  • 相关阅读:
    回顾Oracle几个用到的基本语句
    JDBC连接数据库中CallableStatement执行有参存储过程及注解其他
    JDBC连接数据库步骤及Class.forName()(转)
    Web开发的编码解决中文乱码
    Filter,Listener(转)
    web.xml 中的listener、 filter、servlet 加载顺序及其详解(转)
    算法训练 比赛安排
    算法训练 字符串编辑
    算法训练 最大值与最小值的计算
    算法训练 判定数字
  • 原文地址:https://www.cnblogs.com/yinghualuowu/p/6040707.html
Copyright © 2011-2022 走看看