十进制转为x进制的递归代码

 1 #include <stdio.h>
 2 void fun(int n,int x)
 3 {
 4     if(n==0) return;
 5     else 
 6     {
 7         fun(n/x,x);
 8         printf("%d",n%x);
 9     }
10 }
11 int main()
12 {
13     int n,x;
14     scanf("%d%d",&n,&x);
15     if(n==0) printf("0\n");
16     else fun(n,x);
17     return 0;
18 }

 

相关文章:

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