資源簡介
識別一次讀入的一個以@為結(jié)束符的字符序列是否為形如‘序列1&序列2’模式的字
符序列。其中序列1 和序列2 中都不含字符‘&’,且序列2 是序列1 的逆序列。例如,‘a(chǎn)+b&b+a’是屬該模
式的字符序列,而‘1+3&3-1’則不是。
代碼片段和文件信息
#include
#include
typedef?struct?node
{
char?data;
struct?node?*next;
}linkstack*lp;
void?initstack(linkstack?**A)
{
(*A)=(linkstack*)malloc(sizeof(linkstack));
(*A)->next=NULL;
}
void?push(linkstack?*topchar?x)
{
????linkstack?*temp;
????temp=(linkstack*)malloc(sizeof(linkstack));
????temp->data=x;
????temp->next=top->next;
????top->next=temp;
}
void?pop(linkstack?*topchar?*x)
{
if(top->next!=NULL)
{
linkstack?*temp;
temp=top->next;
top->next=temp->next;
*x=temp->data;
評論
共有 條評論