14001: 【原4001】加法
题目
题目描述
author: sunnywkn 原OJ链接:https://acm.sjtu.edu.cn/OnlineJudge-old/problem/4001
加法
Description
这道题和大家熟知的A+B的唯一区别是在输入信息中加入了很多空格什么的。
Input Format
输入仅有一行,原有的信息保证A+B的格式:例如 12324+3532 但可能在中间加入了一些无用的空格,原数据的相对位置不变 保证A,B为正整数,并且输入数据不找过1Kb 保证60%的数据没有多余空格
Output Format
输出一行: 如果答案大于10^8输出"Large"(不包括引号),否则直接输出答案
Sample Input
1 + 2
Sample Output
3
satgo1546's solution
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
unsigned long long a = 0, b = 0, *p = &a;
while ((argc = getchar()) >= ' ') {
if (strchr("0123456789", argc)) {
*p *= 10;
*p += argc - '0';
if (*p >= 100000000) goto large;
} else if (argc == '+') {
p = &b;
}
}
a += b;
if (a >= 100000000) goto large;
printf("%d\n", a);
return 0;
large:
puts("Large");
return 0;
}