⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 operate_stack.h

📁 数据结构课程设计报告,虽然好多地方都有
💻 H
字号:

#define MAXSIZE 50
/*==================================*/
/*结构体定义                        */
/*==================================*/
typedef struct{
	int data[MAXSIZE];
	int top;
}Stack;


/*==================================*/
/*建立空的顺序栈                    */
/*==================================*/
void Empty_Stack(Stack *S)
{
	S->top=-1;   //置空
}

/*==================================*/
/*输入顺序栈                        */
/*==================================*/
void Insert_Stack(Stack *S, int scan_max)
{
	int scan_x, i;
	for(i=0; i < scan_max; i++)
	{
		printf("元素%d=",i+1);
		scanf("%d",&scan_x);
		/*插入新元素             */
		S->top++;
		S->data[S->top]=scan_x;
	}
}


/*==================================*/
/*显示顺序栈                        */
/*==================================*/
void Print_Stack(Stack S)
{
	int i;
	if(S.top==-1)
		printf("空栈\n");
	else
	{
		for(i=0; i<=S.top; i++)
		{
			printf("%d",S.data[i]);
		}
	}
	printf("\n");
}

	
/*==================================*/
/*出栈                              */
/*==================================*/
void Push_Stack(Stack *S, int *temp)
{
	if(S->top==-1)
		printf("空栈\n");
	else
	{
		/*取元素,修改TOP           */
		*temp=S->data[S->top];
		S->top--;
	}
}

	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -