1797.cpp

来自「杭电 acm部分代码 有兴趣的可以下载 谢谢」· C++ 代码 · 共 70 行

CPP
70
字号
#include <iostream>
#include <string>
using namespace std;
string str;
int main()
{
    int test, i, flag;
    cin >> test;
    while (test--)
    {
        cin >> str;
        i = 0;
        while (str[i] == 'a')
        {
            i++;
        }
        if (i < 1)
        {
            cout << "NO" << endl;
            continue;
        }
        if (str[i] != 'b' || str[i + 1] != 'a')
        {
            cout << "NO" << endl;
            continue;
        }
        i += 2;
        if (str[i] == 'b')
        {
            i++;
            if (str[i] != 'd')
            {
                cout << "NO" << endl;
                continue;
            }
            while (str[i] == 'd')
            {
                i++;
            }
        }
        else
        {
            while (str[i] == 'd')
            {
                i++;
            }
        }
        if (str[i] != 'h')
        {
            cout << "NO" << endl;
            continue;
        }
        i++;
        flag = 0;
        for(;i < str.length();i++)
        {
            if (str[i] != 'f' && str[i] != 'k')
            {
                flag = 1;
                cout << "NO" << endl;
                break;
            }
        }
        if (flag == 0)
        {
            cout << "YES" << endl;
        }
    }
    return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?