You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
423 B

#include<bits/stdc++.h>
using namespace std;
int flag=1; /* check: n/d == 0 */
void trans_num(int n, int d) {
int mod;
mod=n%d;
n=n/d;
while(flag && n)
trans_num(n,d);
flag=0;
if(mod>=10)
mod=mod-10+65; /* convert to char */
else
mod=mod+48;
printf("%c", mod); /* print char (%c) */
}
int main() {
int n, d;
printf("Enter n d: ");
scanf("%d %d", &n, &d);
trans_num(n, d);
printf("\n");
return 0;
}