#include <stdio.h>
#include <vector>
using namespace std;
int a,b;
vector<int >v;
int main(){
// freopen("/Users/pantingting/Documents/code/data/input", "r", stdin);
scanf("%d%d",&a,&b);
int ans=a+b;
// printf("%d\n",ans);
if (ans<0) {
ans*=-1;
printf("-");
}
int count=0;
if (ans!=0) {
while (ans!=0) {//将每个数位都分解
int tmp=ans%10;
ans/=10;
v.push_back(tmp);
count++;
if (count%3==0) {
v.push_back(-1);
}
}
int flag=0;
for (int i=v.size()-1; i>=0; i--) {
if (v[i]==-1)
if (i==v.size()-1) {
continue;
}
else
printf(",");
else
{
printf("%d",v[i]);
flag=1;
}
}
puts("");
}
else
printf("0\n");
return 0;
}
PAT 1001. A+B Format (20)
最新推荐文章于 2022-03-31 10:41:10 发布