#include <stdio.h>
#include <string.h>
void convto(char *s, int n, int b)
{
    char bit[]={"0123456789ABCDEF"};
    int len;
    if(n==0)
    {
        strcpy(s,"");
        return;
    }
    convto(s, n/b, b);
    len = strlen(s);
    s[len] = bit[n%b];
    s[len+1] = '\0';
}

void main(void)
{
    char s[80];
    int i, base,old;
    printf("请输入十进制数:");
    scanf("%d",&old); 
    printf("请输入转换的进制:");
    scanf("%d", &base);
    convto(s, old, base);
    printf("%s\n", s);
    getch();
    return;
}

 

相关文章:

  • 2022-01-19
  • 2022-12-23
  • 2021-12-23
  • 2021-07-15
  • 2021-10-15
  • 2021-10-09
  • 2021-12-28
  • 2021-11-19
猜你喜欢
  • 2022-12-23
  • 2022-01-13
  • 2022-12-23
  • 2021-07-07
  • 2021-11-01
  • 2021-05-29
  • 2021-10-19
相关资源
相似解决方案