求助快读快写
  • 板块学术版
  • 楼主Zjc20120331
  • 当前回复2
  • 已保存回复2
  • 发布时间2023/1/23 15:14
  • 上次更新2023/10/24 03:16:31
查看原帖
求助快读快写
654928
Zjc20120331楼主2023/1/23 15:14

想研究一下快读快写,结果a+b用快读快写WA了,可以看下吗?

code:

#include <iostream>

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


inline void write(int res){
    if (res < 0){
        res = -res;
        putchar('-');
    }
    if (res == 0){
        putchar('0');
        return ;
    }
    while (res){
        putchar(res%10+'0');
        res /= 10;
    }
	return ;
}

int main(){
    int a, b;
    a = read();
    b = read();
    write(a+b);
    return 0;
}
2023/1/23 15:14
加载中...