如何提高cin的读取效率

在主函数下加入一句 ios::sync_with_stdio(false);

在代码中加入这句语句可以提高cin读入数据的速度,使得cin读入数据的能力和scanf相当

int main() {

  int n;

  ios::sync_with_stdio(false);

    cin>>n;

  ....

}

posted @ 2020-11-27 15:56  爱努力的人最幸福  阅读(124)  评论(0)    收藏  举报