📄 addlink.cpp
字号:
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
struct node{
int item;
struct node *next;
};
typedef struct node NADE;
NADE *start,*cur;
void create()
{
int i;
cur=new node;
printf("enter the num");
scanf("%d",&i);
cur->item=i;
start=cur;
scanf("%d",&i);
while(i!=-99)
{
cur->next=new node;
cur=cur->next;
cur->item=i;
scanf("%d",&i);
}
cur->next=NULL;
cur=start;
}
void display()
{
NADE *nod=start;
while(nod!=NULL)
{
printf("[%d] =>",nod->item);
nod=nod->next;
}
printf("NULL");
}
void add()
{ int i,j;
NADE *node1, *node2;
node1=new node;
node2=start;
while(node2!=NULL)
{printf("enter the term");
scanf("%d",&i);
if(i==1)
{
printf("enter the value");
scanf("%d",&j);
node1->item=j;
node1->next=node2->next;
node2->next=node1;
}
node2=node2->next;
} }
void main()
{
create();
display();
add();
display();
getch();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -