c++ 快读

c++快读

读自然数

#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
inline long long rd(){
	register int x=0;
	register char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x;
}

读整数

#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
inline long long rd(){
    register int x=0,f=0;register char ch=getchar();
    while(ch<'0'||ch>'9')f|=ch=='-',ch=getchar();
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return f?-x:x;
}

以上快读调用:

读入

x=rd();
原文地址:https://www.cnblogs.com/Lour688/p/13204479.html