#include <stdio.h>
#include <string>
#include <iostream>
#include <sstream>
#define LL long long
using namespace std;
int main(){
LL a,b;
scanf("%lld%lld",&a,&b);
LL c = a+b;
stringstream ss; //转换为string
string s;
ss<<c;
ss>>s;
//cout<<s<<endl;
int l = s.length(); //计算出要加的“,”个数t
if(c<0)l-=1;
int t = l/3;
int h = l%3;
if(h==0)t-=1;
l=s.length(); //从后向前插入
for(int i=1;i<=t;i++){
s.insert(l-i*3,",");
}
cout <<s;
return 0;
}
PAT 1001 A+B Format (20分)笔记
最新推荐文章于 2021-08-19 12:01:54 发布