当前位置:网站首页>Convert the decimal positive integer m into the number in the forward K (2 < =k < =9) system and output it in bits

Convert the decimal positive integer m into the number in the forward K (2 < =k < =9) system and output it in bits

2022-06-26 16:45:00 Muzi..

#include<stdio.h>
#include<stdlib.h>
void fun(int m,int k);
int main()
{
    
	 int b,n;
	 printf("\n please enter a number and a base:\n");
	 scanf("%d %d",&n,&b);
	 fun(n,b);
	 printf("\n");
}
void fun(int m,int k)
{
    
	int aa[20],i;
	for(i=0;m;i++)
	{
    
		 aa[i]=m%k;
		 m=m/k;
	}
	for(;i;i--)
	{
     
	   printf("%d",aa[i-1]);
	}
}
原网站

版权声明
本文为[Muzi..]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202170506477895.html