读入优化

来源:互联网 发布:2017网络规划师真题 编辑:程序博客网 时间:2024/06/06 04:43

   读入优化之所以速度快于普通的scanf原因是使用了getchar(),也不知道为什么,反正getchar()的速度非常快,所以读入优化的速度是高于scanf的。

#include<cstdio>template <typename Type> inline void Read(Type &in){Type f=1;char ch=getchar();for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') f=-1;for(;ch>='0'&&ch<='9';ch=getchar()) in=in*10+ch-'0';in*=f;}int main(){return 0;}



0 0