0And1Story / 0And1Story.github.io

My Blog.
https://0And1Story.github.io
GNU General Public License v3.0
1 stars 0 forks source link

BlogPostAssets/articles/fast-io #3

Open utterances-bot opened 5 years ago

utterances-bot commented 5 years ago

快读 - 0And1Story Blog

undefined

https://0and1story.github.io/BlogPostAssets/articles/fast-io.html

SocialZxy commented 5 years ago

我记得快输用的是递归吧......这样直接printf不就没意思了吗QwQ

0And1Story commented 5 years ago

@SocialZxy

我记得快输用的是递归吧......这样直接printf不就没意思了吗QwQ

递归?怎么个递归法?我觉得重载运算符更好啊。。。而且我总觉得printf在有些时候比putchar更快啊QAQ

SocialZxy commented 5 years ago
void write(int x)
{
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

话说你是怎么回复的啊QwQ

SocialZxy commented 5 years ago

@0And1Story

0And1Story commented 5 years ago

@SocialZxy

void write(int x)
{
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

话说你是怎么回复的啊QwQ

像这样:

@SocialZxy 

> ```cpp
> void write(int x)
> {
>     if(x<0) putchar('-'),x=-x;
>     if(x>9) write(x/10);
>     putchar(x%10+'0');
> }
> ```
> 
> 话说你是怎么回复的啊QwQ

还有我觉得用递归的话好像比printf更慢呢。。。

SocialZxy commented 5 years ago

@0And1Story 您测一下不就知道了(

0And1Story commented 5 years ago

@SocialZxy

@0And1Story 您测一下不就知道了(

以前我测过一次,printf("%s")putchar更快。。。