📄 ll.c
字号:
#include<stdio.h>
#include<conio.h>
#include<alloc.h>
#define null 0
struct list
{
int info;
struct list *link;
};
void main()
{
int i,num,check;
struct list *l,*k,*x,*z,*m,*temp;
clrscr();
l=(struct list*)malloc(sizeof(struct list));
k=l;
z=l;
do
{
printf("\n Choose your option");
printf("\n 1- Create a linked list");
printf("\n 2- Display");
printf("\n 3- Insert at the end");
printf("\n 4- Insert in between");
printf("\n 5- Exit\n");
scanf("%d",&i);
switch(i)
{
case 1:
printf("\nEnter the data");
printf("\n Type -1 to exit");
do
{
x=k;
scanf("%d",&x->info);
k=(struct list*)malloc(sizeof(struct list));
x->link=k;
}while(x->info!=-1);
x->link=NULL;
break;
case 2:
l=z;
printf("\n The numbers entered are: ");
do
{
printf("\n%d\n", l->info);
l=l->link;
}while(l!=NULL);
break;
case 3:
printf("\n Enter the number you want to insert");
scanf("%d",&num);
k=z;
while(k->info!=-1)
{
k=k->link;
}
x=k;
k->info=num;
k=(struct list*)malloc(sizeof(struct list));
x->link=k;
k->info=-1;
k->link=NULL;
break;
case 4:
k=z;
printf("\n Enter the number you want to insert");
scanf("%d",&num);
printf("\n Enter the number after which you want to insert");
scanf("%d",&check);
while(k->info!=check)
{
k=k->link;
}
temp=k->link;
x=k;
k=(struct list*)malloc(sizeof(struct list));
k->info=num;
x->link=k;
k->link=temp;
break;
}
}while(i!=5);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -