十-八進制轉換

#include<stdio.h>
#include <stdlib.h>
typedef struct node
{
	int data;
	struct node *next;
}node;
int main()
{
	int m,n;
	node *p,*q,*top;
	top=(struct node *)malloc(sizeof(struct node));
	top->next=NULL;
	scanf("%d",&m);
	while(m!=0)
	{
		p=(struct node *)malloc(sizeof(struct node));
		n=m%8;
		p->data=n;
		p->next=top->next;
		top->next=p;
		m=m/8;
		
	}
	while(top->next!=NULL)
	{
		top=top->next;
		printf("%d",top->data); 
	}
	printf("\n");
	return 0;
	
} 

發佈了68 篇原創文章 · 獲贊 5 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章