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

📄 operate_lnode.h

📁 数据结构课程设计报告,虽然好多地方都有
💻 H
字号:
/*==================================*/
/*结构体定义                        */
/*==================================*/
typedef struct lnode{
	int data;
	struct lnode *next;
}L_node;

/*====================================*/
/*输入栈                              */
/*====================================*/
void Insert_node(L_node **node, int scan_max)
{
	int i,scan_x;
	L_node *temp;
	temp=(L_node *)malloc(sizeof(L_node));
	if(temp!=NULL)
	{
		for(i=0; i<scan_max; i++)
		{
			printf("元素%d=",i+1);
			scanf("%d",&scan_x);
			temp->data=scan_x;
			/*新节点指向栈顶指针 并修改栈顶指针  */
			temp->next=(*node);
			(*node)=temp;
			temp=(L_node *)malloc(sizeof(L_node));
		}
	}
}



/*====================================*/
/*显示栈                              */
/*====================================*/
void Print_node(L_node *node)
{
	L_node *Strat=node;
	if(Strat==NULL)
		printf("空栈\n");
	else
	{
		while(Strat->next!=NULL)
		{
			printf("%d",Strat->data);
			Strat=Strat->next;
		}
		printf("%d",Strat->data);
	}
}


/*====================================*/
/*取栈顶                              */
/*====================================*/
void Push_node(L_node **node)
{
	int x;
	L_node *free_l=(*node);
	x=free_l->data;
	/*修改栈顶,释放栈顶         */
	(*node)=(*node)->next;
 	free(free_l);
	printf("栈顶元素[%d]\n",x);
}



⌨️ 快捷键说明

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