📄 function.cpp
字号:
#include "stdafx.h"
#include "head.h"
#include "stdio.h"
#include "malloc.h"
status push(sqstack &L,SElemType e)
{
*L.top++=e;
return OK;
}
status pop(sqstack &L,SElemType &e)
{
if (L.top==L.base) return ERROR;
e=*--L.top;
return OK;
}
status stackEmpty(sqstack L)
{
if (L.base==L.top) return TRUE;
else return FALSE;
}
status function(sqstack &L)
{
int k,j,b,d;
char a,e,f;
k=j=b=d=0;
L.base=(SElemType *)malloc(STACK_INIT_SIZE*sizeof(SElemType));
L.top=L.base;
L.stacksize=STACK_INIT_SIZE;
while(1)
{
scanf("%c",&a);
if (a=='('||a=='[')
push (L,a);
if(a==')') f='(';
if(a==']') f='[';
if (a==')'||a==']')
{
if(*(L.top-1)==f) pop(L,e);
else
if(a==')') k++;
else j++;
}
if (a==';') break;
}
while(!stackEmpty(L))
{
pop(L,e);
if(e=='(') b++;
if(e=='[') d++;
}
if(stackEmpty(L)&&b==0&&d==0&&k==0&&j==0)
{
printf("true!\n");
return TRUE;
}
printf("you miss %d '('\n",k);
printf("you miss %d ')'\n",b);
printf("you miss %d '['\n",j);
printf("you miss %d ']'\n",d);
return OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -