我程序编完了,不会改。谁帮我改好了,我就把所有的分都给谁!
我的题目是:用链栈实现将十进制数转化为八进制数,我编完了,可我不会改啊,都改了无数个日夜了,还是改不好。有哪位好心的人能帮帮我啊?将不胜感激啊!。程序就在下面,帮帮忙,救救我吧,交不上程序我就挂了啊。呜呜呜呜呜#include<stdio.h>
#include<math.h>
struct node
{
int data;
struct node *next;
}LinkStack;
void init_stack(struct node *top)
{
top->data='-1';
top->next=NULL;
}
int decide_empty(struct node *top)
{
if(top->data=='-1')
return (1);
else
return (0);
}
void Enter_stack(struct *top,int x)
{ ;
top=(LinkStack*)malloc(sizeof(LinkStack));
top->data=x;
top->next=top;
printf("\nOK!\n");
return(top);
}
int del_stack(struct *top)
{
if(top==NULL)
{
printf("\n栈为空!");
}
else
{
top=top->next;
free(top);
}
}
main()
{
stacklist L;
int n,e;
L=init_stack(struct node *top);
printf("please input a decimal number:");
scanf("%d,&n");
if(n<=0)
printf("error due to the wrong input!\n");
while(n)
{
Enter_stack( L ,n%8);
n=n/8;
}
printf("the changed number is:\n");
while(decide_empty(L))
{
e=del_stack(L);
printf("%d",e);
}
}
[[it] 本帖最后由 zitong1987611 于 2008-4-19 11:57 编辑 [/it]]