This commit is contained in:
Павел Родионов
2025-11-13 18:21:23 +07:00
parent e266a25b45
commit 2fca7b75f5
28 changed files with 74 additions and 4 deletions
+28
View File
@@ -0,0 +1,28 @@
#include <stdio.h>
void to_base_n(unsigned long *n, int *b);
int main(void){
unsigned long num;
int bin;
printf("Enter: num base(2-10)\t(q to quit):\n");
printf("Enter: ");
while (scanf(" %ld %d", &num, &bin) == 2){
if(bin>1&&bin<11){
to_base_n(&num,&bin);
putchar('\n');
printf("Enter: ");
}else(printf("base is out of range\nEnter: "));
}
return 0;
}
void to_base_n(unsigned long *n, int *b){
int r;
r = *n % *b;
if (*n >= *b){
*n = *n / *b;
to_base_n(n,b);
}
putchar('0' + (r % *b));
return;
}