【模拟】小X的加法难题

一个字符一个字符的输入。没什么好说的。错误原因:打少了一个0.

#include<cstdio>
char c;
long long a,b;
int main(){
	c=getchar();
	while(c!='+'){
		if(c<='9'&&c>='0') a=a*10+c-48;
		if(a>100000000) break;
		c=getchar();
	}
	if(a>100000000) {
		printf("Large");
		return 0;
	}
	c=getchar();
	while(c>0&&c!='\n'){
		if(c<='9'&&c>='0') b=b*10+c-48;
		if(b>100000000) break;
		c=getchar();
	}
	if(b>100000000||a+b>100000000){
		printf("Large");
		return 0;
	}
	printf("%lld",a+b);
} 

猜你喜欢

转载自blog.csdn.net/qq_42937087/article/details/89282058