算法竞赛常用小技巧

常用小技巧

1. 将cin 和cout 输入输出时间减小到跟scanf和printf差不多:

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

2. 涉及到文件的输入输出:


#include<stdio.h>
int main()
{
    int a,b;
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    while(scanf("%d %d",&a,&b)!=EOF)
    printf("%d\n",a+b);
} //运行后直接自动建立了一个out.txt文本在程序目录下

猜你喜欢

转载自www.cnblogs.com/DengSchoo/p/12628197.html