有高手帮我改改这个程序

来源:百度知道 编辑:UC知道 时间:2024/06/07 23:43:07
运行时候有一个错误 (改对了再加高分)
#include<stdio.h>
#define NULL 0
typedef struct node
{char ch;
struct node *next;}
Snode,*stack;
main()
{ stack s,top,p;
char ch;
int choice;
s=(stack)malloc(sizeof(Snode));
s->ch='!';
s->next=NULL;
top=s;
scanf("%c",&ch);
getchar();
while(ch!='!')
{ p=(stack)malloc(sizeof(Snode));
p->ch=ch;
p->next=top;
top=p;
scanf("%c",&ch);
getchar();
}
while(p->next!=NULL)
{
printf("%c-->",p->ch);
p=p->next
}
printf("\n");
printf("shu ru 1 jin zhan shu ru 2 chu zhan qi ta tui chu\n");
scanf("%d",&choice);
getchar();
while(choice==1||choice==2)
{ if(choice==1)
{

printf("\n shu ru jin zhan yuan su\n");
scanf("%c",&c

缺少#include <malloc.h>
第28行少一个分号
最后一行少个}

修改后
#include<stdio.h>
#include <malloc.h>
#define NULL 0
typedef struct node
{char ch;
struct node *next;}
Snode,*stack;
main()
{ stack s,top,p;
char ch;
int choice;
s=(stack)malloc(sizeof(Snode));
s->ch='!';
s->next=NULL;
top=s;
scanf("%c",&ch);
getchar();
while(ch!='!')
{ p=(stack)malloc(sizeof(Snode));
p->ch=ch;
p->next=top;
top=p;
scanf("%c",&ch);
getchar();
}
while(p->next!=NULL)
{
printf("%c-->",p->ch);
p=p->next;
}
printf("\n");
printf("shu ru 1 jin zhan shu ru 2 chu zhan qi ta tui chu\n");
scanf("%d",&choice);
getchar();
while(choice==1||choice==2)
{ if(choice==1)
{