快速输入输出功能 [英] Fast input output function

查看:154
本文介绍了快速输入输出功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#define getcx getchar_unlocked
inline void inp( int &n )//fast input function
{
   n=0;
   int ch=getcx();int sign=1;
   while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();}

   while(  ch >= '0' && ch <= '9' )
           n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
   n=n*sign;
}

Hi我一直使用上述函数来输入各种编码比赛,但是永远不能理解为什么它是快。我知道逻辑,但不知道它的坚牢的概念。例如,这行是什么#define getcx getchar_unlocked。此外,我不知道任何快速输出函数,所以有任何快速输出函数也

Hi I have been using the above function for input in various coding contests but was never able to understand why is it fast. I know the logic but don't know the concept of it's fastness. For example what is this line doing "#define getcx getchar_unlocked" . Also I don't know any fast output function so is there any fast output function also

推荐答案

#define 使用预处理器使 getcx 成为函数 getchar_unlocked() ,这是一个非锁定字符阅读功能。

The #define uses the preprocessor to make getcx be a short-hand for the function getchar_unlocked(), which is a non-locking character-reading function.

这是一个有点可怕,你参加了几个编码比赛,没有理解这个漂亮的基本的C。

It's a bit awesome that you've competed in several coding contests without understanding this pretty basic piece of C.

手册页我链接到上面提到的 putc_unlocked()听起来几乎是一样的东西,但输出。

The manual page I linked to above mentions putc_unlocked() which sounds like pretty much the same thing but for output.

这篇关于快速输入输出功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆