?? kuohaopipei.cpp
字號:
//刮號匹配的檢驗kuohaopipei.cpp
#include<iostream.h>
#include<malloc.h>
#include<iomanip.h>
#include<stdlib.h>
typedef char Status;
typedef char SElemType;
#include "stack.cpp"
void main()
{SqStack *p;
int n,m=32,q=0;
char ch,ca,cd;
cout<<"kuohaopipei.cpp運行結果:\n";
cout<<"輸入括號字符序列:";
p->InitStack(&p);
for(n=1;n<m;n++)
{cin>>ch;
if(ch=='[') p->Push(ch);
if(ch=='(') p->Push(ch);
if(ch=='{') p->Push(ch);
if(ch==']')
{ca=p->Pop(&cd);
if(ca=='[') cout<<ca<<"與"<<ch<<"是匹配的!\n";
else
{cout<<ca<<"與"<<ch<<"不是匹配的!\n";q++;}}
if(ch==')')
{ca=p->Pop(&cd);
if(ca=='(') cout<<ca<<"與"<<ch<<"是匹配的!\n";
else
{cout<<ca<<"與"<<ch<<"不是匹配的!\n";q++;}}
if(ch=='}')
{ca=p->Pop(&cd);
if(ca=='{') cout<<ca<<"與"<<ch<<"是匹配的!\n";
else
{cout<<ca<<"與"<<ch<<"不是匹配的!\n";q++;}}
if(p->StackEmpty()) break;}
if(q>=1) cout<<"刮號序列不匹配!\n";
else cout<<"刮號序列匹配!\n";
cin.get();cin.get();}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -