文档介绍:-
. z.
实验报告
课程
数据构造
实验名称
实验二 堆栈和队列
**
**
实验日期:
2021/10/18
实验二 堆栈和队列
实验目的:
{
printf("堆栈已空出错!");
return 0;
}
*d = p->data;
return 1;
}
/*撤销*/
void Destroy(LSNode *head)
{
LSNode *p, *p1;
p = head;
while(p != NULL)
{
p1 = p;
p = p->ne*t;
free(p1);
}
}〔2〕主函数程序:
*include<>
*include<>
typedef int DataType;
*include ""
void main(void)
{ LSNode *myStack;
int i, *;
StackInitiate(&myStack);
for(i=0;i<5; i++)
{ if(StackPush(myStack,i+1)==0)
{
printf("error!\n");
return;
}
}
if(StackTop(myStack, &*)==0)
{
printf("error!\n");
return;
}
-
. z.
else
printf("The element of local top is :%d\n",*);
printf( "The sequence of outing elements is:\n");
while(StackNotEmpty(myStack))
{
StackPop(myStack, &*);
printf("%d ", *);
}
printf("\n");
Destroy(myStack);
printf("This program is made by10273206\n");
}
运行结果为:
〔3〕设计构造体和测试函数如下:
*include<>
*include<>
*include<>
typedef struct{
char taskName[10];
int taskNo;
}DataType;
*include""
void main(){
LSNode *myStack;
FILE *fp;
DataType task,*;
if((fp=fopen("*t","r"))==NULL){
printf("*t!\n");