国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設(shè)計 > 正文

PAT A1001. A+B Format (20)

2019-11-11 02:45:04
字體:
供稿:網(wǎng)友

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

Each input file contains one test case. Each case contains a pair of integers a and b where -1000000 <= a, b <= 1000000. The numbers are separated by a space.

Output

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 9Sample Output
-999,991
#include <cstdio>#include <algorithm>#include <cmath>#include <cstring>#define Max 100001using namespace std;int main(){	int a,b,m[100]={0},sum,f=0,k=0,p=0,q=0;	char num[100]={};	int R[100];	for(int i=0;i<100;i++)	{		R[i]=0;	}	scanf("%d%d",&a,&b);	sum=a+b;	if(sum<0) 	{		PRintf("-");		sum=-sum;	}	if(sum==0) printf("0/n");	else {	k=0;	while (sum>0)	{        k++;		m[f++]=sum%10;		sum/=10;		if(sum==0) break;		if(k==3)		{			k=0;			m[f++]=11;		}	}		for(int i=f-1;i>=0;i--)	{		if(m[i]>=10)			printf(",");		else printf("%d",m[i]);	}	printf("/n");}	system("pause");	return 0;}
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 余姚市| 仙游县| 泰来县| 突泉县| 奎屯市| 南康市| 河间市| 山丹县| 镇赉县| 长兴县| 赤城县| 汝州市| 灵璧县| 湘潭县| 东光县| 长治县| 芦山县| 乌海市| 长子县| 利川市| 昆明市| 安仁县| 甘德县| 武胜县| 赤峰市| 松潘县| 临湘市| 彭阳县| 衡山县| 连云港市| 平塘县| 山西省| 黄大仙区| 双鸭山市| 迭部县| 贵阳市| 南投县| 滨海县| 双柏县| 克什克腾旗| 屏东县|