include "stdio.h"
include "stdlib.h"
include "conio.h"
void del(int data);
void insert(int value);
void display();
struct node
{
int data;
struct node *link;
};
struct node *top=NULL,*temp, *temp1, *temp2, *temp3;
int main()
{
int choice,data;
while(1) //infinite loop is used to insert/delete infinite number of elements in linked list
{
printf("\n1.Insert\n2.Delete\n3.Display\n4.Exit\n");
printf("\nEnter ur choice:");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("Enter a new element :");
scanf("%d",&data);
insert(data);
break;
case 2:
printf("Enter the value to be deleted from sorted linked list :");
scanf("%d",&data);
del(data);
break;
case 3:
display();
break;
case 4:
exit(0);
}
}
getch();
return 0;
}
void insert(int data)
{
temp=(struct node *)malloc(sizeof(struct node));
temp->data=data;
if(top == NULL)
{
temp->link=NULL;
top=temp;
}
else // top not null
{
temp1 = top ;
while(temp1 != NULL)
{
if(temp1->data >= data) // list element is smaller ...
{
if(temp1 == top) // list element is head ...
{
temp->link = temp1;
top = temp;
break;
}
else // list element is not head ..
{
temp->link = temp1;
temp2->link = temp;
break;
}
}
else
{
if(temp1->link == NULL)
{
temp->link = NULL;
temp1->link = temp;
break;
}
else
{
temp2 = temp1;
temp1 = temp1->link;
}
}
}
}
// creating a space for the new element.
}
void del(int data)
{
struct node *temp,*var;
temp=top;
int i=0;
while(temp!=NULL)
{
if(temp->data == data)
{ i = 1; // Flag ..
if(temp==top)
{
top=temp->link;
free(temp);
break;
}
else
{
var->link=temp->link;
free(temp);
break;
}
}
else
{
var=temp;
temp=temp->link;
}
}
if(i == 1)
{
printf("data deleted from list is %d",data);
}
else
{
printf("\n The required data, %d is not found in the list. go look somewhere else",data);
}
}
void display()
{
temp=top;
if(temp==NULL)
{
printf("\nStack is empty\n");
}
while(temp!=NULL)
{
printf(" %d ->",temp->data);
temp=temp->link;
}
}
include "stdlib.h"
include "conio.h"
void del(int data);
void insert(int value);
void display();
struct node
{
int data;
struct node *link;
};
struct node *top=NULL,*temp, *temp1, *temp2, *temp3;
int main()
{
int choice,data;
while(1) //infinite loop is used to insert/delete infinite number of elements in linked list
{
printf("\n1.Insert\n2.Delete\n3.Display\n4.Exit\n");
printf("\nEnter ur choice:");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("Enter a new element :");
scanf("%d",&data);
insert(data);
break;
case 2:
printf("Enter the value to be deleted from sorted linked list :");
scanf("%d",&data);
del(data);
break;
case 3:
display();
break;
case 4:
exit(0);
}
}
getch();
return 0;
}
void insert(int data)
{
temp=(struct node *)malloc(sizeof(struct node));
temp->data=data;
if(top == NULL)
{
temp->link=NULL;
top=temp;
}
else // top not null
{
temp1 = top ;
while(temp1 != NULL)
{
if(temp1->data >= data) // list element is smaller ...
{
if(temp1 == top) // list element is head ...
{
temp->link = temp1;
top = temp;
break;
}
else // list element is not head ..
{
temp->link = temp1;
temp2->link = temp;
break;
}
}
else
{
if(temp1->link == NULL)
{
temp->link = NULL;
temp1->link = temp;
break;
}
else
{
temp2 = temp1;
temp1 = temp1->link;
}
}
}
}
// creating a space for the new element.
}
void del(int data)
{
struct node *temp,*var;
temp=top;
int i=0;
while(temp!=NULL)
{
if(temp->data == data)
{ i = 1; // Flag ..
if(temp==top)
{
top=temp->link;
free(temp);
break;
}
else
{
var->link=temp->link;
free(temp);
break;
}
}
else
{
var=temp;
temp=temp->link;
}
}
if(i == 1)
{
printf("data deleted from list is %d",data);
}
else
{
printf("\n The required data, %d is not found in the list. go look somewhere else",data);
}
}
void display()
{
temp=top;
if(temp==NULL)
{
printf("\nStack is empty\n");
}
while(temp!=NULL)
{
printf(" %d ->",temp->data);
temp=temp->link;
}
}
jual jam tangan g shock kw super 1
ReplyDeletejual jam tangan g shock kw super 1
www.jamtangankeren.net
Mancungin Hidung
kemejaflanell.wordpress.com
jualjamtanganironsamurai.wordpress.com
jualmadumanukaaslijakartaindonesia
Jual Madu Manuka
jual usb flashdisk murah lucu unik 4gb 8gb 16gb 32gb
jualjamtangangshock.wordpress.com
jasaseobacklinkmurahterbaikberkualitasindonesia
nanajasaseo.wordpress.com
jualpowerbanklucuunikmurahkaskusvivan
layanan-spiritual.blogspot.com
sarungsholatberkualitas.wordpress.com
this is too good :) www.eshopori.com nice to read this
ReplyDeleteIt has the capability to captivate anyone mind like me; It's no one but electrical engineering pe exam which attract me the plenty of times after reading its high-flown website and blogsite. I wanna join in pe in electrical engineering engineering for my betterment. I hope It gives me exact taining. For further info you will have to log in its web portal.
ReplyDelete
ReplyDeleteनोटबंदी के 50वें दिन, मोदी सरकार के फैसले से निराश हैं जनता
Readmore todaynews18.com https://goo.gl/NJUQY9
thank you for your sharing this good informatoins
ReplyDeletegoldenslot casino
บาคาร่าออนไลน์
gclub casino
thank you!
nice post and your post is always full of information.
ReplyDeleteDate Sheet
We at COEPD provides the best web Designing course in Hyderabad. Your search to learn web designing technology ends here at COEPD. Here, we are an established training institute who have trained more than 10,000 participants in all streams. We will help you to convert your passion to learn into an enriched learning process. At COEPD, we provide finest web designing technology covering Photoshop, HTML, CSS, HTML5, CSS3, JavaScript, Boot Strap, and JQuery. We train participants to be solution providers and creative engineers.
ReplyDeletehttp://www.coepd.com/WebDesigning.html
A couple of speculation concerning these issues on a corporate zone, and Offshore Software improvement may help you with regulating them. If you have some problem with Hp Printer Offline click the link.
ReplyDelete