91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

數(shù)據(jù)結構例程。。。 按照陳越姥姥的筆記寫的。。。

資源截圖

代碼片段和文件信息

#include
#include
#include
#include

#define?init_size?20
#define?increment?20

typedef?char?ElemType;

typedef?struct?sqStack
{
ElemType?*top;
ElemType?*base;
int?stack_size;
};

void?init_stack(?sqStack?*s)
{
s->base?=?(?ElemType*)malloc(init_size?*?sizeof(?ElemType?)?);
if?(?!s->base?)
exit(0);

s->top?=?s->base;
s->stack_size?=?init_size;
}

void?push(?sqStack?*s?ElemType?e)
{
if?(?s->top?-?s->base?>=?s->stack_size?){
s->base?=?(ElemType?*)realloc(?s->base??(s->stack_size?+?increment)?*?sizeof(?ElemType)?);
if?(?!s->base)
exit(0);
}

*(s->top)?=?e;
s->top++;

}

void?pop(?sqStack?*s?ElemType?*e)
{
if?(?s->top?==?s->base)
return?;

s->top?--;
*e?=?*(s->top);
}

int?stacklen(?sqStack?*s)
{
return?s->top?-?s->base;
}

int?main(void)
{
sqStack?s;
init_stack(&s);
char?str[100];
ElemType?temp;
int?i?=?0;

char?e;
scanf(“%c“?&e);

while?(?e?!=?‘\n‘)
{
while?(?isdigit(e))?//分離數(shù)字?
{
printf(“%c“?e);
scanf(“%c“?&e);
}
printf(“?“);

if?(?‘*‘==e?||?‘/‘==e?||?‘(‘==e)?//?*?/?直接入棧?
{
push(?&s?e);
}

else?if?(?‘)‘==?e?)??//?反括號一直彈棧直至正括號?
{
do
{
pop(?&s?&temp);
printf(“%c?“?temp);
}while?(?‘(‘?!=?temp);
}

else?if?(?‘+‘==e?||?‘-‘==e)?//加減號?
{
if?(?!stacklen(&s)?)?//?如果空棧,?直接入棧?
{
push(?&s?e);
}
else
{
do
{
pop(&s?&e);
if?(?‘(‘?==?e)
push(&se);
else
printf(“%c?“?e);
}while(?stacklen(&s)?&&?‘(‘?!=?e);

push(?&s?e);
}

}
else?if?(?e?!=?‘\n‘)
{
printf(“error!\n“);
return?-1;
}

if?(?e?!=?‘\n‘)
scanf(“%c“?&e);
}

while(?stacklen(&s))
{
pop(&s?&e);
printf(“%c?“?e);
}

printf(“\n“);
}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????1047??2015-10-18?16:12??堆棧的鏈表實現(xiàn).cpp

?????文件????????969??2015-10-18?16:10??堆棧的數(shù)組實現(xiàn).cpp

?????文件???????1401??2015-10-18?16:25??隊列的鏈表實現(xiàn).cpp

?????文件???????1072??2015-10-18?16:17??隊列的數(shù)組實現(xiàn).cpp

?????文件???????1627??2015-10-18?21:14??二叉樹的遍歷.cpp

?????文件???????2449??2015-10-18?20:30??平衡二叉樹.cpp

?????文件???????1685??2015-10-18?18:45??搜索二叉樹.cpp

?????文件???????1894??2015-10-18?21:19??中綴表達式轉換為逆波蘭表達式.cpp

-----------?---------??----------?-----??----

????????????????12144????????????????????8


評論

共有 條評論