insertchainbelt.cpp
来自「一个用于展示数据结构中插入」· C++ 代码 · 共 38 行
CPP
38 行
#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 + =
减小字号Ctrl + -
显示快捷键?