读入优化

int read()
{
    char c;int ff=1;
    while((c=getchar())<'0'||c>'9')
        if(c=='-')ff=-1;
    int num=c-'0';
    while((c=getchar())>='0'&&c<='9')
        num=num*10+c-'0';
    return ff*num;
}

输出优化

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

 

相关文章:

  • 2022-02-12
  • 2021-08-09
  • 2021-08-19
  • 2021-11-29
  • 2022-01-07
  • 2021-09-19
猜你喜欢
  • 2022-12-23
  • 2020-05-25
  • 2022-12-23
  • 2021-10-21
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案