Skip to content

Instantly share code, notes, and snippets.

@growvv
Created September 6, 2021 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save growvv/07707bba5814a858c245e6ebc0832a93 to your computer and use it in GitHub Desktop.
Save growvv/07707bba5814a858c245e6ebc0832a93 to your computer and use it in GitHub Desktop.
打印整数n的b进制
/*
* Print an unsigned integer in base b.
*/
printn(n, b)
long n;
{
register long a;
if (n<0) { /* shouldn't happen */
putchar('-');
n = -n;
}
if(a = n/b)
printn(a, b);
putchar("0123456789ABCDEF"[(int)(n%b)]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment