口腔技师考试都考什么:谁能帮我运行一下这程序看有错吗

来源:百度文库 编辑:神马品牌网 时间:2024/04/16 12:38:19
#include<stdio.h>
#define NULL 0
typedef struct node
{int data;
struct node *link;
}NODE;
NODE *top;

void Push(x)
int x;
{NODE *p;
p=(NODE *)malloc(sizeof(NODE));
p->data=x;
p->link=top;
top=p;
}

int pop()
{NODE *P;
int x;
if(top!=NULL)
{p=top;
x=p->data;
top=top->link;
free(p);
}
return (x);
}

void ShowStack()
{NODE *p;
p=top;
if(p->date==0)
printf("\t\t\t 栈中无元素!\n);
else
{printf("\t\t\t 栈中站的元素从栈顶到栈底: ");
while(p->data!=0)
{printf("%6d",p->data);
p=p->link;
}
}

void Conversion()
{
int x;
top->data=0;
top->link=NULL;
printf("\n\t\t\t 请输入一个十进制数: ");
scanf("%d",&x);
while(x!=0)
{Push(x%8);
x=x/8;
}
printf("\n\t\t\t");
while(top->data!=0)
{x=Pop();
printf("%d",x);
}
}

void main()
{
char choice;
int i=1,j=1;
int x;
top=(NODE *)malloc(sizeof(NODE));
top->data=0;
top->link=NULL;
while(i)
{
printf("\n\n\n\n");
printf("\t\t\t-链栈--\n");
printf("\n\t\t\t*****************************************");
printf("\n\t\t\t* 1-------入 栈 *****");
printf("\n\t\t\t* 2-------出 栈 *****");
printf("\n\t\t\t* 3-------显示栈元素 *****");
printf("\n\t\t\t* 4-------进制的转换 *****");
printf("\n\t\t\t* 0-------退 出 *****");
printf("\n\t\t\t*****************************************");
printf("\t\t\t 请择菜单号(0--4): ");
scanf("%c",&choice);getchar();
if(choice=='1')
{
while(j)
{printf("\n\t\t\t 请输入要入栈的数字(输入0结束): ");
printf("\n\t\t\t");
scanf(%d",&x);getchar();
if(x!=0)
Push(x);
else
j=0;
}
}
else if(choice=='2')
{
x=Pop();
/*printf("\t\t\t 出栈的元素为: %d",x);*/
}
else if(choice=='3')
ShowStack();
else if(choice=='4')
{
Conversion();
getchar();
}
else if(choice=='0')
{i=0;
printf("\t\t\t 程序结束!\n");
}
else printf("\n\t\t\t 输入错误! 请重新输入! \n");
}
}
我机子运行不出结果 我用的是 Microsoft Visual C++ 6.0 看看在你们机子上能不 试试看编的有错没 拜托了

要在你们机子上看看能运行吗 我的运行不了 测下我的用软件是有问题不

是啊,你总得把大概的思想告诉我们吧??不然我们这么糊里糊涂的运算也不一定能找出问题所在啊!

这么长,讲讲写这个程序干什么?就这么看好辛苦啊