can any one translate the following codes into c++ codes, coz i can't run
the "printf" command in Unix and it said it's implicit declaration.
Is it only the two lines with comment need to be re-written??
Thanks a lot
void _display_number (int v, int n){
if(v >= 1000){
int r = v % 1000;
_display_number (v / 1000,n);
printf(",%03d", r); // how to translate that into
std::cout<<...?
}else{
printf("%s%d\n" ,n ? "-":"",v); // how to translate??
}
}
void display_number( int v){
_display_number (v < 0 ? -v : v,v < 0);
}
the "printf" command in Unix and it said it's implicit declaration.
Is it only the two lines with comment need to be re-written??
Thanks a lot
void _display_number (int v, int n){
if(v >= 1000){
int r = v % 1000;
_display_number (v / 1000,n);
printf(",%03d", r); // how to translate that into
std::cout<<...?
}else{
printf("%s%d\n" ,n ? "-":"",v); // how to translate??
}
}
void display_number( int v){
_display_number (v < 0 ? -v : v,v < 0);
}
Comment