读入优化板子

来源:互联网 发布:唐斯体测数据 编辑:程序博客网 时间:2024/06/05 05:14

读入优化板子。。。

版本一

#include<bits/stdc++.h>using namespace std;int n;void read(int &_x){    int sum=0,fu=1;_x=0;    char c=getchar();    while(c<'0'||c>'9'){        if(c=='-') fu=-1;        c=getchar();    }    while(c>='0'&&c<='9'){        sum*=10;        sum+=c-'0';        c=getchar();    }    _x=sum*fu;}int main(){    read(n);    cout<<n;}

版本二

#include<bits/stdc++.h>using namespace std;inline char get_char(){    static const int L=1<<15;    static char buffer[L];    static char *C,*mempool;    if(C==mempool) mempool=(C=buffer)+fread(buffer,1,L,stdin);    if(C==mempool) return EOF;    return *C++;}inline int get_int(){    int re=0;    char c;    do c=get_char();while(c<'0' || c>'9');    while(c<='9' && c>='0')    {        re=(re<<1)+(re<<3)+c-'0';        c=get_char();    }    return re;}int main(){    int n;    cin>>n;    n=get_int();    cout<<n<<endl;    return 0;}
原创粉丝点击