L1-6 吃火锅 (15分)

想法

这个题都15分 是不是有点简单了 连边界条件都不用判断:如果n ichi1 huo3 guo1? 前面是和其他相连,这样需要判断一下两边的情况。
比赛的时候我还判断了一下,这次直接写个find就过了。姥姥太仁慈了。

#include <iostream>
using namespace std;
int main()
{
    
    
    string s;
    int cnt = 0, index = 1;
    int first = 0;
    while (1)
    {
    
    
        getline(cin, s);
        if (s == ".")
            break;
        if (s.find("chi1 huo3 guo1") != -1)
        {
    
    
            if (first == 0)
                first = index;
            cnt++;
        }
        index++;
    }
    cout << index - 1 << endl;
    if (cnt == 0)
        cout << "-_-#";
    else
        cout
            << first << " " << cnt;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_45653525/article/details/110448903
今日推荐