这是我写的,但是最后一个三位也会有逗号,比如1,000,000,希望大家给个解决方法,谢谢
#include<iostream>
using namespace std;
void showCommas(int);
int main(){
showCommas(1000000);
return 0;
}
void showCommas(int number)
{
if(number > 0){
showCommas(number / 1000);
if((number % 1000) == 0){
cout << number % 1000 << "00,";
}
else
cout << number % 1000 << ",";
}
}