#include <stdio.h>
#include <stdlib.h>
int count=0;
struct node{
int data;
struct node *next;
};
struct node *head=NULL,*temp;
void Insert(int d){
struct node *newnode;
newnode= (struct node*) malloc(sizeof(struct node));
if(newnode==NULL)
{
printf("not there
");
}
else{newnode->data= d;
newnode->next=NULL; }
if(head==NULL)
{
head=newnode;temp=newnode; count++;
}
else
{
temp->next=newnode;
temp=newnode;
count++;
}
}
void Display(){
struct node*temp;
temp=head;
while(temp!=NULL){
printf("%d,",temp->data);
temp=temp->next;
}
printf("
", );
}
void main()
{ int c=0;int d;
do{
printf("choose an option: 1. Insert at begining 2. Insert at end 3. Insert at specified position
4.Delete from begining 5.Delete from end 6. Delete from specified position 7.Insert
8. Exit
");
scanf("%d",&c);
switch (c) {
case 7: printf("enter element
");
scanf("%d",&d);Insert(d);Display();break;
default : c=8; break;
}
}while(c!=8);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…