1001. A+B Format (20)

#include<stdio.h>
#include<string.h>
int main()
{
int a,b,c;
int j;
char buff[100];
char ss[100];
int n;
scanf("%d%d",&a,&b);
c=a+b;
if(c<0)
sprintf(buff,"%d",-c);
else
sprintf(buff,"%d",c);
if(c<0)
printf("-"); 
n=strlen(buff);
for(int i=0;i<n;i++)
{
printf("%c",buff[i]);
if((n-i-1)%3==0&&(n-i)>3)
printf(",");
}
}

 

posted @ 2017-03-04 14:57  yaoyibin  阅读(107)  评论(0编辑  收藏  举报