这题非常简单,因为只需要用三步表达式就可以了,不多说我直接上代码
Code
#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;
}