【一月份 -- 基础语法组】-- T1 --人品计算

· · 个人记录

网址: https://cspjs.online/contest/648/problem/1

题解: https://b1bznc26af6.feishu.cn/file/BhbVbYsdhoFCulx1xfXcc9Pwnmb?from=from_copylink

#include <bits/stdc++.h>
using namespace std;
char c[200010];
int main() {
    freopen("count.in", "r", stdin);
    freopen("count.out", "w", stdout);
    int n, cnt = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    for (int i = 0; i < n; i++) {
        if (c[i] == 'C') {
            if (c[i + 1] == 'S') {
                if (c[i + 2] == 'P')
                    cnt++;
            }
        }
    }
    cout << cnt;
    return 0;
}