C语言程序十进制的数转换成八进制的数的办法:
#include
#include
void main()
{
int n,a,sum = 0,i =0;
printf("十进制输出一个数n\n");
scanf("%d",&n);
while(n)
{
a = n%8;
n = n/8;
sum += a*pow(10,i);
i++;
}
printf("八进制输出sum:%d",sum);
}
#include
#include
void main()
{
int n,a,sum = 0,i =0;
printf("十进制输出一个数n\n");
scanf("%d",&n);
while(n)
{
a = n%8;
n = n/8;
sum += a*pow(10,i);
i++;
}
printf("八进制输出sum:%d",sum);
}