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 −106≤a,b≤106. 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:
-999,991
题意:给出两个整数,要求按每三位数字插入一个逗号的格式输出两数之和。
思路:用一个字符数组接收两数之和,根据数组下标的值判断是否需要插入一个逗号。
代码:
#include<stdio.h>
int main(void){
int a