跳到正文

题解

题解:P11395 喵喵喵幼儿园

Tendo_Alice约 2 分钟
原文
文章信息与版本

文章信息

发布
2025年9月19日
收录
2025年12月12日
更新
2026年11月13日
篇幅
约 2 分钟
题目
P11395

版本

  1. v1当前

题解:P11395 喵喵喵幼儿园

传送门

题目分析:

qq 次询问,每次给你两个字符串,输出不是 eat 的字符串,否则输出 or。

思路:

按顺序去判断两个字符串,只要有一个字符串不是 eat 那就输出,否则输出 or。

Code:

C++
#include<bits/stdc++.h>
#define IOSO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define endl '\n'
#define QwQ return 0;
using namespace std;
int main(){
    IOSO;
    int n;
    cin>>n;
    string eat="eat";
    for(int i=1;i<=n;i++){
        string A,B,C;
        cin>>A>>C>>B;
        string word=B.substr(0,B.size()-1);//删除字符串后面的?
        if(A!=eat){//如果A字符串不是eat,那就输出A
            cout<<A<<endl;
        }else if(word!=eat){//如果B字符串不是eat,那就输出B
            cout<<word<<endl;
        }else{//如果两个字符串都是eat,那就输出or
            cout<<"or"<<endl;
        }
    }
    QwQ;
}
原文
存档评论1 条抓取于