#include #include int main() { int n,b; int lastcolvalue; printf("Input n and b: "); scanf("%d%d",&n,&b); fprintf(stderr,"n is %d and b is %d\n",n,b); lastcolvalue = 1; // value of the units column while ( lastcolvalue <= n/b ) { lastcolvalue *= b; // move one column left } fprintf(stderr,"lastcolvalue is %d\n", lastcolvalue); while ( lastcolvalue > 0 ) { printf(" %d ",n/lastcolvalue); n = n%lastcolvalue; lastcolvalue /= b; // move right one column } printf("\n"); return EXIT_SUCCESS; }