【题目描述】
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).
【输入】
Only one line. Contains two integers a and b(-1000000≤a, b≤1000000). The numbers are separated by a space.
【输出】
#include <stdio.h> #include <stdlib.h> int main() { int a,b,x,i,j=0; scanf("%d %d",&a,&b); x=a+b; if(x<0) { printf("-"); x=-x; } int m[10]; for(i=0;x>0;i++) { m[i]=x%10; x=x/10; j++; } for(i=j-1;i>=0;i--) { printf("%d",m[i]); if(i==9||i==6||i==3) printf(","); } return 0; }
Only one line. Output the sum of a and b in one line. The sum must be written in the standard format.
【样例输入】
-1000000 9↙
【样例输出】
-999,991
标签:int,sum,1000000,Only,printf,第六章,line From: https://www.cnblogs.com/xrj1229/p/16874263.html