lshkelly
发表于 2017-5-7 23:59:48
需要,支持鱼C论坛
崔aoge
发表于 2017-5-23 12:56:54
想看啊啊啊啊啊
wangjia911
发表于 2017-5-30 17:49:04
支持小甲鱼
a850698824
发表于 2017-6-8 20:08:22
这么强,点个赞
JokerKing
发表于 2017-6-16 12:45:40
辛苦了
lh625243422
发表于 2017-6-17 23:17:49
学习下甲鱼老师
阳光加冰
发表于 2017-7-5 13:59:27
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAXSIZE 128
typedef struct
{
char *base, *top;
int capacity;
} Stack;
int InitStack(Stack *pstack)
{
pstack -> base = pstack -> top = (char*)malloc(sizeof(char) * MAXSIZE);
if(!pstack -> base)
return 0;
pstack -> capacity = MAXSIZE;
return 1;
}
int Push(Stack *pstack, char ch)
{
if(pstack -> top - pstack -> base >= pstack -> capacity)
{
pstack -> base = (char*)realloc(pstack -> base, (pstack -> capacity + 10) * sizeof(char));
pstack -> top = pstack -> base + pstack -> capacity;
pstack -> capacity += 10;
}
*(pstack -> top++) = ch;
}
void Pop(Stack *pstack, char *ch)
{
*ch = *(--pstack -> top);
}
int Empty(Stack *pstack)
{
return(pstack -> top - pstack -> base == 0);
}
int main()
{
Stack mStack;
char buffer;
int i, len;
InitStack(&mStack);
gets(buffer);
len = strlen(buffer);
for(i = 0; i < len; i++)
{
/*if(buffer == '(')
{
if(i + 1 < len && buffer == ')')
{
i += 1;
continue;
}
}
else if(buffer == '[')
{
if(i + 1 < len && buffer == ']')
{
i += 1;
continue;
}
}*/
if(buffer == '(' || buffer == '[' || buffer == '{' || buffer == '<')
Push(&mStack, buffer);
else if(buffer == ')' || buffer == ']' || bufffer == '}' || buffer == '>')
{
char temp;
Pop(&mStack, &temp);
if((temp == '(' && buffer == ')') || (temp == '[' && buffer == ']') ||
(temp == '{' && bufffer == '}') || (temp == '<' && buffer == '>'))
continue;
else {
printf("isn't matched.\n");
return 0;
}
}
}
if(Empty(&mStack))
printf("matched.\n");
else
printf("isn't matched.\n");
return 0;
}
shaury
发表于 2017-7-8 14:45:37
学习
莱昂纳多
发表于 2017-7-20 10:31:59
1
ssytec
发表于 2017-7-25 09:40:06
来看看
坏小子
发表于 2017-8-13 13:50:04
这个功能不错,虽然我没用栈~~~
梦完何能又不念
发表于 2017-8-18 18:06:00
瞅瞅
gitgit
发表于 2017-8-21 16:08:50
感谢小甲鱼老师
血狼小强强
发表于 2017-8-22 14:15:49
赞一个,谢谢
zishan097
发表于 2017-8-22 16:53:16
支持
hpsh666
发表于 2017-9-22 21:58:28
下载一个
xiaocangshu886
发表于 2017-9-25 23:02:46
y
wcw123456
发表于 2017-9-27 18:15:11
答案
wcw123456
发表于 2017-9-27 18:19:13
。
百年c++
发表于 2017-9-30 09:17:46
遇到注释呢?