int mai" />
Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - In C++, if you want to output integers not in normal decimal format but in hexadecimal binary format, what should you do?
In C++, if you want to output integers not in normal decimal format but in hexadecimal binary format, what should you do?

Hexadecimal output

printf("%x\n",a);

Binary output is more troublesome

# include

void f(int n)

{

if(n)

f(n/2 );

else

return;

printf("%d\n",n%2);

}

p>

int main(void)

{

int n;

while(1)

{

scanf("%d",&n);

if(n<0) break;

if(n==0) printf("0");

f(n);

printf("\n");

}

return 0;

< p>}