音乐游戏 简单模拟,字符串,cin.get,getchar,流同步(女赛)

结论 :

  • 如果要关闭流同步ios::sync_with_stdio(false),就不能使用 g e t c h a r ( ) getchar() getchar(),但可以改用 c i n . g e t ( ) cin.get() cin.get()
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <stack>
#include <unordered_set>

using namespace std;

typedef long long ll;

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

    int _ = 1;
//    cin >> _;

    while (_ -- )
    {
    
    
        int n, cnt = 0;
        cin >> n;
//        getchar();
        cin.get();
        for (int i = 1; i <= n; i ++ )
        {
    
    
            string str;
            getline(cin, str);
            for (int j = 0; j < str.size(); j ++ )
                if (str[j] == '-') cnt ++ ;
        }
        cout << cnt << endl;
    }

    return 0;
}

おすすめ

転載: blog.csdn.net/m0_51448653/article/details/121231635