C++模板:快速读入

#include<bits/stdc++.h>
inline int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(!isdigit(ch))//等价于while(!(ch>='0' && ch<='9'))
    {
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(isdigit(ch))//等价于while(ch>='0' && ch<='9') 
    {
        s=s*10+ch-'0';
        ch=getchar();
    }
    return s*f;
}
using namespace std;
int main()
{
    int n;
    n=read();
    cout<<n;
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/SuperTer/p/CPP-model-1.html
今日推荐