c++加速cin和关闭同步流

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0) , cout.tie(0);
    int T = 1;
//    cin >> T ;
    while(T--) solve();
    return 0;
}
一· ios::sync_with_stdio(false);
01 "c++是否兼容stdio(c)"的开关函数

02 默认参数为 true : 将输出流绑到一起 保证程序不发生io混乱
// cin会将要输出的东西先存入缓冲区再输出

03 false : 关闭 cin 与 stdio 的同步 打消 iostream 的输入输出缓存
// 关闭同步后不要混用 cin/cout 和 scanf/printf
// 建议使用 false 而不是 0 // 上保险???!

二· cin.tie(0); cout.tie(0);

关闭cin和cout绑定 // 绑定时 每次 << 都会调用 flush

三 减少 endl 的使用

01 每次 endl 都会调用 flush
02 关了同步流一定要用 endl !!! // '\n' 不显示结果的
posted @ 2024-02-03 14:06  伊芙加登  阅读(2651)  评论(0)    收藏  举报