#include
int main(void)
{
int data = 0;
char y;
printf("输入一个10进制整歼卜数\基改渣n");
scanf("%d"搏悄, &data);
while(1)
{
data = data / 8;
y = data % 8;
printf("%c", y + '0');
if(data == 0)
{
printf("\n");
break;
}
}
return 0;
}
这旦念仔个程序就可以了,vc6通过调试,用数字模汪测试结果正确
#include
void main()
{
int i,num=0,t=0;
printf("input a number:");
scanf("%d",&num);
while(num>0)
{
t=t*10;
t+=num%8;
num/=8;
}
num=0;
while(t>0)
{
num=num*10;
num+=t%10;
t/=10;
}
printf("result is:O%d\n"高侍,num);
}
int a, b, i = 1;
scanf( "%d", &a );
while( a /行游败磨渣 8 > 0 )
{
b += (a%8) * i;
i *= 10;
a /档颤= 8;
}
printf("%d",b);
#include <纤滑stdio.h>
int main(void)
{
int x, i = 0, j, flag = 0;
char arr[100];
printf("input the number:");
scanf("%d", &x);
if (x < 0)
{
x = -x;
flag = 1;
}
while (x > 0)
{
arr[i] = x % 8 + '0';
x = x / 8;
i++;
}
if (flag == 1)
{
printf("贺竖空-");
}
for (j = i - 1; j >= 0; j--)
{
printf("%c"禅瞎, arr[j]);
}
return 1;
}