码迷,mamicode.com
首页 > 其他好文 > 详细

快速读入输出模板

时间:2018-07-28 11:57:17      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:color   col   line   style   ret   getch   putc   快速   int   

inline int read()
{
    char ch = getchar();
    int x = 0, f = 1;
    while(ch < ‘0‘ || ch > ‘9‘)
    {
        if(ch == ‘-‘) f = -1;
        ch = getchar();
    }
    while(‘0‘ <= ch && ch <= ‘9‘)
    {
        x = x * 10 + ch - ‘0‘;
        ch = getchar();
    }
    return x * f;
}

inline void put(int x)
{
    if (x < 0)
        x = ~x + 1, putchar(‘-‘);
    if (x > 9)
        put(x / 10);
    putchar(x % 10 + ‘0‘);
}

 

快速读入输出模板

标签:color   col   line   style   ret   getch   putc   快速   int   

原文地址:https://www.cnblogs.com/longl/p/9380756.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!