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.
46 lines
585 B
46 lines
585 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;
|
|
switch(mod) {
|
|
case 10:
|
|
printf("A");
|
|
break;
|
|
case 11:
|
|
printf("B");
|
|
break;
|
|
case 12:
|
|
printf("C");
|
|
break;
|
|
case 13:
|
|
printf("D");
|
|
break;
|
|
case 14:
|
|
printf("E");
|
|
break;
|
|
case 15:
|
|
printf("F");
|
|
break;
|
|
default:
|
|
printf("%d", mod);
|
|
}
|
|
|
|
}
|
|
int main() {
|
|
int n, d;
|
|
printf("Enter n d: ");
|
|
scanf("%d %d", &n, &d);
|
|
|
|
trans_num(n, d);
|
|
printf("\n");
|
|
return 0;
|
|
}
|
|
|