📄 huiwenshu.c
字号:
#include <stdio.h>
#define false -1
#define OK 1
#define StackElementType char
typedef struct node
{ StackElementType data;
struct node *next;
}LinkStackNode;
typedef LinkStackNode *LinkStack;
/*初始化堆栈*/
void InitStack(LinkStack *top)
{ *top=(LinkStack)malloc(sizeof(LinkStackNode));
(*top)->next=NULL;
}
/*进栈函数*/
int Push(LinkStack top,StackElementType x)
{ LinkStackNode *temp;
temp=(LinkStackNode *)malloc(sizeof(LinkStackNode));
if(temp==NULL)
return (false);
temp->data=x;
temp->next=top->next;
top->next=temp;
return (OK);
}
/*出栈函数*/
int Pop(LinkStack top,StackElementType *x)
{ LinkStackNode *temp;
temp=top->next;
if(temp==NULL)
return (false);
top->next=temp->next;
*x=temp->data;
free(temp);
return (OK);
}
main()
{ LinkStack Q;
StackElementType *C,c1,c2;
C=NULL;
InitStack(&Q);
printf("please input some chars that include(&):\n");
scanf("%c",&c1);
while(c1!='%')
{ if(c1=='&')
break;
Push(Q,c1);
/* scanf("%c",&c1); */
c1=getchar();
}
/*printf("please output huiwenshu:"); */
/* while(Q->next!=NULL)
{ Pop(Q,C);
printf("%c",*C);
} */
getch();
printf("please input hou ban bu fen chars:");
/* scanf("%c",&c2); */
c2=getchar();
Pop(Q,C);
while(c2!='@')
while((Q->next!=NULL)&&(c2==*C))
{ Pop(Q,C);
/* scanf("%c",&c2); */
c2=getchar();
}
getch();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -