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

输入输出优化

时间:2017-08-29 21:45:12      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:blog   text   putchar   name   algorithm   algo   har   utc   using   

原作者看了不会生气的。对吧。

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;

inline int read()
{
    char ch=getchar();
    int re=0;
    bool fl=1;
    /*
    if (ch==‘-‘)
    {
        re=0;
        ch=getchar();
    }
    */
    while (ch>=0&&ch<=9)
    {
        re=re*10+ch-0;
        ch=getchar();
    }
    return fl?re:-re;
}
inline void write(int re)
{
    /*
    if (re<0)
    {
        putchar(‘-‘);
        re=-re;
    }
    */
    if (re>9) write(re/10);
    putchar(re%10+0);
}
int main()
{
    int n=read(),i,a;
    for (i=1;i<=n;i++)
    {
        a=read();
        write(a);
        putchar(\n);
    }
    return 0;
}

注释的是考虑负数的情况(我觉得最好写上)

输入输出优化

标签:blog   text   putchar   name   algorithm   algo   har   utc   using   

原文地址:http://www.cnblogs.com/hanser/p/7450088.html

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