直接枚举每个字符判断即可。
#include<bits/stdc++.h> using namespace std ; string s ; int n , cnt ; int main() { cin >> n >> s ; for(char c : s) { cnt += (c == '*') ; } cout << cnt ; return 0 ; }
暂无评论