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

首頁 > 學院 > 開發設計 > 正文

PAT A1001. A+B Format (20)

2019-11-11 00:50:22
字體:
來源:轉載
供稿:網友

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;}
上一篇:集合大家族

下一篇:順序串基本操作

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 墨脱县| 嘉定区| 益阳市| 逊克县| 抚宁县| 通城县| 鄂尔多斯市| 平度市| 贡觉县| 苗栗县| 康平县| 阿拉善右旗| 马龙县| 灵璧县| 汾西县| 清苑县| 榆中县| 威海市| 阜康市| 沛县| 剑阁县| 霍林郭勒市| 屏山县| 嘉义市| 修水县| 庄浪县| 云霄县| 宁津县| 新竹市| 景宁| 密云县| 台湾省| 民乐县| 沅陵县| 无棣县| 浦北县| 奎屯市| 韩城市| 哈巴河县| 东宁县| 开原市|