P11034 题解

· · 题解

思路

首先将 st 都各复制出两个新串 s't',将 s't' 所有字母转为大写。然后在新串中使用 find 函数查找是否含有 RIOI 这个字串,然后将四种可能的情况分类讨论即可。

AC CODE

#include<bits/stdc++.h>
using namespace std;

int main(){
    string s,t;
    cin>>s>>t;
    string ns="",nt="";
    for(auto ch:s)
        if(ch>='A'&&ch<='Z')
            ns+=ch;
        else ns+=ch-'a'+'A';
    for(auto ch:t)
        if(ch>='A'&&ch<='Z')
            nt+=ch;
        else nt+=ch-'a'+'A';
    bool fs=(ns.find("RIOI")!=string::npos);
    bool ft=(nt.find("RIOI")!=string::npos);
    if(fs&&ft)
        cout<<"Either is ok!\n";
    else if(fs)
        cout<<s<<" for sure!\n";
    else if(ft)
        cout<<t<<" for sure!\n";
    else cout<<"Try again!\n";
    return 0;
}