【leetcode】千位分隔数
作者:互联网
char * thousandSeparator(int n){ char* s = (char*)calloc(20,1); sprintf(s,"%d",n); int len = strlen(s); if (len <= 3) return s; char* str = (char*)calloc(20,1); int i = len - 1; int count = 0; int j = i + len/3; while(i>=0) { count++; if (count % 4 == 0) { str[j--] = '.'; continue; } str[j--] = s[i--]; } return &str[j+1]; }
标签:count,分隔,千位,--,len,char,int,str,leetcode 来源: https://www.cnblogs.com/ganxiang/p/13591692.html