在一些题目中,需要输入很多的数据,而时间却还限制着,这是我们就需要考虑提高输入效率。scanf的输入效率要高于cin,一般来说cin不能过的用scanf也许就能过,但总有情况需要更高的输入效率,而getchar的输入效率又高于scanf,于是就用这个方法输入数据。
代码如下:
#include <iostream>
using namespace std;
#define re register
inline int read()
{
re int x=0,f=1;
re char ch=getchar();
while(ch<'0'||ch>'9') {if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
return x*f;
}
int main()
{
int x,y;
x=read();
y=read();
cout<<x<<" "<<y<<endl;
return 0;
}