读入优化

1 int read(){
2     int f=1;int x=0;char s=getchar();
3     while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
4     while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
5     x*=f;
6     return x;
7 }

 

posted @ 2018-09-01 16:33  lcan  阅读(159)  评论(0编辑  收藏  举报