跳到正文

个人记录

T651606 题解

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

文章信息

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

版本

  1. v2当前
  2. v1

这题非常简单,因为只需要用三步表达式就可以了,不多说我直接上代码

Code

C++
#include <iostream>
#include <string>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, M;
    char target;
    cin >> N >> M >> target;

    while (N--) {
        string str;
        cin >> str;
        int cnt = 0;
        for (char c : str) if (c == target) cnt++;
        cout << (cnt ? cnt : -1) << '\n';
    }

    return 0;
}
原文