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

📄 insertchainbelt.cpp

📁 一个用于展示数据结构中插入
💻 CPP
字号:
#include"chainbelth.h"




void Insertlist(linklist &l)
{
	linklist p,q;
	int j=0,insertdata,iposition;
	p=l;
	if(l->next!=NULL)
	{
		scanf("%d",&insertdata);
		printf("position=");
		printf("Please input a data which you want to add to the chain belt and the position:\n");
		printf("data=");
		scanf("%d",&iposition);
		while(p&&j<iposition-1)
		{
			p=p->next;
			++j;
		}
		if(!p||j>iposition-1)
			printf("Error! The position is wrong!\n");
		q=(linklist)malloc(sizeof(Lnode));
		if(!q)
			printf("Error!  Do not have enough EMS memory interspace!\n");
		q->data=insertdata;
		q->next=p->next;
		p->next=q;
		printf("The changed chain belt is:\n");
		printout(l);
		printf("\n");
	}
	else 
		printf("You do not have created a chain belt before,please create first:\n");
}

⌨️ 快捷键说明

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