英文描述
1001.A + B Format (20)
Calculate a + b and output the sum in standard format – that is, the digits must be separated into groups of three by commas (unless there are less than four digits).
Input Specification:
Each input file contains one test case. Each case contains a pair of integers a and b where -1 000 000 <= a, b <= 1 000 000. The numbers are separated by a space.
Output Specification:
For each test case, you should output the sum of a and b in one line. The sum must be written in the standard format.
Sample Input:
-1000000 9
Sample Output:
CYJJ 01
-999,991
中文描述
电话账单
用标准的格式输出a + b和,标准格式是这样的:3个数字为一组,通过逗号间隔,如果测试用例少于四个数字就不用间隔。
输入规则:
每个输入文件包含一个测试用例。每个测试用例是一对整数,a和b,a、b的取值范围是-1000000到1000000.a、b之间用空格间隔。
输出规则:
对于每个测试用例,你应该在一行内输出a+b的和。和必须用标准格式输出。
样例输入:
-1000000 9
样例输出:
-999,991
分析与解题
这是开始刷的第一个题,当时写了两个多星期,并且下面的代码是第三次重构,第一次写了400多行,我也是醉醉的。后来看了ZJU的代码只有几十行我就更是醉醉的了。我真不是一个聪明的人,要不也不会写这么多代码了。
C语言实现
1 |
|