跳到正文

个人记录

You too!

AFOed_on_20260726约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月18日
更新
2025年12月27日
篇幅
约 1 分钟

版本

  1. v2当前
  2. v1
C++
#include <iostream>
#include <string>
using namespace std;

int countYoutoo(const string& str) {
    int count = 0;
    string target = "youtoo";
    int targetLen = target.length();

    if (str.length() < targetLen) {
        return 0;
    }

    for (size_t i = 0; i <= str.length() - targetLen; i++) {
        if (str.substr(i, targetLen) == target) {
            count++;
        }
    }
    return count;
}

int main() {
    string input;
    cin>>input;
    int result = countYoutoo(input);
    cout << result << endl;

    return 0;
}
原文