数字的标准写法

    #include <bits/stdc++.h>
    using namespace std;
    #define ll long  long 
    char s[20],p[20];
    int cnt;
    void solve(ll c){
        if(c<0){    
        printf("-");
        c=abs(c);
    }
          cnt  = 0;
        while(c){//为0呢 
            s[cnt++] = char(c%10)+'0';
            c/=10;
        }
        for(int i =0;i<cnt/2;i++){
            p[i] = s[i];
            s[i]  =s[cnt-1-i];
            s[cnt-1-i] = p[i];
        }
        for(int i =0;i<cnt;i++){
            printf("%c",s[i]);
            int x =cnt-1-i;
            if(x%3==0&&i!=cnt-1){//数字的标准写法,要从后往前每3个一个, 
                printf(",");
            }
        }
    }
    int main()
    {
        ll a,b;
        scanf("%lld%lld",&a,&b);
        if(a+b==0){
            printf("0
");
        }
        else
        solve(a+b);
        return 0;
    }
    
        
原文地址:https://www.cnblogs.com/tingtin/p/11537358.html