括号匹配检查c语言,c 语言 检查括号匹配 不能运行 ????
各位請幫我看一下這個東西, 我要在c語言中實現括號匹配,設計思路:把從鏈棧中掃描得到的'}',‘]',')'先存儲到動態申請的內存空間中,當掃描到‘{','[','('時 在彈出先前存儲的’)‘,’]','}' 比較,來檢測是否匹配
但是在運行中程序不動了,就麻煩??
linkstack.h:
typedef char ElemData;
typedef struct node
{
ElemData data;
struct? node *next;
}LSnode,*Lstack;
typedef struct nodel
{
ElemData tdata;
struct nodel *tnext;
}TLSnode,*TLsnode;
linkedStack.cpp:
#include
#include
#include
#include"linkstack.h"
Lstack GetData()
{
Lstack head;
LSnode *p;
head = NULL;
for(int i = 0; ;i++)
{
p =(LSnode*)malloc(sizeof(LSnode));
scanf("%c",&p->data);
p->next=head;
head = p;
if(p->data == '\n')
break;
}
return (head);
}
//元素出棧
int? display(LSnode *p)
{int L=0;
LSnode *l;
l=p->next;
while(p!=NULL)
{
printf("%c",p->data);
p=p->next;
L++;
}
printf("\n");
return L;
}
//算術表達式括號�
總結
以上是生活随笔為你收集整理的括号匹配检查c语言,c 语言 检查括号匹配 不能运行 ????的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 路由器信道选择哪个好路由器信道选择哪个最
- 下一篇: android cpu hotplug,