Академический Документы
Профессиональный Документы
Культура Документы
#include <stdio.h>
#include<conio.h>
#include<alloc.h>
#define NULL 0
struct node
int info;
};
NP *first,*temp,*prev,*last;
void main()
int x;
char c;
clrscr();
while(1)
printf("\n M E N U\n");
printf("*************\n\n");
printf("1.Creation.\n");
printf("2.Display.\n");
printf("3.Exit.\n\n");
scanf("%d",&x);
switch(x)
case 1:
crea();
break;
case 2:
disp();
break;
case 3:
exit();
}
crea()
char y;
do
scanf("%d",&temp->info);
if(first==NULL)
first=temp;
prev=temp;
else
prev->add=temp;
prev=temp;
flushall();
y=getch();
}while(y=='y' || y=='Y');
return;
disp()
clrscr();
prev=first;
printf("FIRST ->");
do
printf("%d ->",prev->info);
prev=prev->add;
}while(prev!=NULL);
printf("LAST");
return;
#include<conio.h>
#include<alloc.h>
#define NULL 0
struct node
int info;
};
NP *first,*temp,*prev,*last;
void main()
int x;
char c;
clrscr();
while(1)
{
printf("\n M E N U\n");
printf("*************\n\n");
printf("1.Creation.\n");
printf("2.Display.\n");
printf("3.Searching\n");
printf("4.Exit.\n\n");
scanf("%d",&x);
switch(x)
case 1:
crea();
break;
case 2:
disp();
break;
case 3:
search();
break;
case 4:
exit();
}
crea()
char y;
do
scanf("%d",&temp->info);
if(first==NULL)
first=temp;
prev=temp;
else
prev->add=temp;
prev=temp;
flushall();
y=getch();
}while(y=='y' || y=='Y');
return;
search()
int s;
int p=0;
int fl=0;
scanf("%d",&s);
prev=first;
do
p=p+1;
if(prev->info==s)
fl=1;
break;
else
prev=prev->add;
}
}while(prev!=NULL);
if(fl==1)
else
return;
disp()
clrscr();
prev=first;
printf("FIRST ->");
do
printf("%d ->",prev->info);
prev=prev->add;
}while(prev!=NULL);
printf("LAST");
return;
#include <stdio.h>
#include<conio.h>
#include<alloc.h>
#define NULL 0
struct node
int info;
};
NP *first,*temp,*prev,*last;
void main()
{
int x;
char c;
clrscr();
while(1)
printf("\n M E N U\n");
printf("*************\n\n");
printf("1.Creation.\n");
printf("2.Display.\n");
printf("3.Searching\n");
printf("4.Find Sum\n");
printf("5.Exit.\n\n");
scanf("%d",&x);
switch(x)
case 1:
crea();
break;
case 2:
disp();
break;
case 3:
search();
break;
case 4 :
find_sum();
break;
case 5:
exit();
find_sum()
int s=0;
prev=first;
do
s=s+prev->info;
prev=prev->add;
}while(prev!=NULL);
return;
crea()
{
char y;
do
scanf("%d",&temp->info);
if(first==NULL)
first=temp;
prev=temp;
else
prev->add=temp;
prev=temp;
flushall();
y=getch();
}while(y=='y' || y=='Y');
return;
search()
int s;
int p=0;
int fl=0;
scanf("%d",&s);
prev=first;
do
p=p+1;
if(prev->info==s)
fl=1;
break;
else
prev=prev->add;
}while(prev!=NULL);
if(fl==1)
else
return;
disp()
clrscr();
prev=first;
printf("FIRST ->");
do
printf("%d ->",prev->info);
prev=prev->add;
}while(prev!=NULL);
printf("LAST");
return;
#include <stdio.h>
#include<conio.h>
#include<alloc.h>
#define NULL 0
struct node
int info;
};
NP *first,*temp,*prev,*last;
void main()
int x;
char c;
clrscr();
while(1)
printf("\n M E N U\n");
printf("*************\n\n");
printf("1.Creation.\n");
printf("2.Display.\n");
printf("3.Searching\n");
printf("4.Find Sum\n");
printf("5.Exit.\n\n");
scanf("%d",&x);
switch(x)
case 1:
crea();
break;
case 2:
disp();
break;
case 3:
search();
break;
case 4 :
find_sum();
break;
case 5:
exit();
find_sum()
int s=0;
prev=first;
do
s=s+prev->info;
prev=prev->add;
}while(prev!=NULL);
return;
crea()
char y;
first=temp=NULL; // Asigning null to the structure pointers
do
scanf("%d",&temp->info);
if(first==NULL)
first=temp;
prev=temp;
else
prev->add=temp;
prev=temp;
flushall();
y=getch();
}while(y=='y' || y=='Y');
return;
}
search()
int s;
int p=0;
int fl=0;
scanf("%d",&s);
prev=first;
do
p=p+1;
if(prev->info==s)
fl=1;
break;
else
prev=prev->add;
}while(prev!=NULL);
if(fl==1)
{
printf("\nMsg : Milgaya Milgaya at position %d!\n\n",p);
else
return;
disp()
clrscr();
prev=first;
printf("FIRST ->");
do
printf("%d ->",prev->info);
prev=prev->add;
}while(prev!=NULL);
printf("LAST");
return;
}
/* Counting repeation of the nodes of same info.*/
#include <stdio.h>
#include<conio.h>
#include<alloc.h>
#define NULL 0
struct node
int info;
};
NP *first,*temp,*prev,*last;
void main()
int x;
char c;
clrscr();
while(1)
printf("\n M E N U\n");
printf("*************\n\n");
printf("1.Creation.\n");
printf("2.Display.\n");
printf("3.Searching\n");
printf("4.Repeat Count\n");
printf("5.Exit.\n\n");
scanf("%d",&x);
switch(x)
case 1:
crea();
break;
case 2:
disp();
break;
case 3:
search();
break;
case 4 :
repeat_count();
break;
case 5:
exit();
repeat_count()
int r=0;
int s;
scanf("%d",&s);
prev=first;
do
if(prev->info==s)
r++;
prev=prev->add;
}while(prev!=NULL);
clrscr();
crea()
char y;
do
scanf("%d",&temp->info);
if(first==NULL)
first=temp;
prev=temp;
else
prev->add=temp;
prev=temp;
}
flushall();
y=getch();
}while(y=='y' || y=='Y');
return;
search()
int s;
int p=0;
int fl=0;
scanf("%d",&s);
prev=first;
do
p=p+1;
if(prev->info==s)
fl=1;
break;
else
{
prev=prev->add;
}while(prev!=NULL);
if(fl==1)
else
return;
disp()
clrscr();
prev=first;
printf("FIRST ->");
do
printf("%d ->",prev->info);
prev=prev->add;
}while(prev!=NULL);
printf("LAST");
return;
/* Inserting an node */
#include <stdio.h>
#include<conio.h>
#include<alloc.h>
#define NULL 0
struct node
int info;
};
void main()
int x;
char c;
clrscr();
while(1)
printf("\n M E N U\n");
printf("*************\n\n");
printf("1.Creation.\n");
printf("2.Display.\n");
printf("3.Searching\n");
printf("4.Inserting\n");
printf("5.Exit.\n\n");
scanf("%d",&x);
switch(x)
case 1:
crea();
break;
case 2:
disp();
break;
case 3:
search();
break;
case 4 :
ins();
break;
case 5:
exit();
ins()
int p;
int pos;
int i=0;
temp=NULL;
scanf("%d",&p);
temp->add=NULL;
scanf("%d",&temp->info);
switch(p)
case 1:
temp->add=first;
first=temp;
break;
case 2:
prev=first;
do
prev=prev->add;
}while(prev->add!=NULL);
prev->add=temp;
prev=temp;
break;
case 3:
scanf("%d",&pos);
prev=first;
while(i<pos-2)
i++;
prev=prev->add;
};
temp->add=prev->add;
prev->add=temp;
break;
return;
crea()
char y;
do
scanf("%d",&temp->info);
if(first==NULL)
first=temp;
prev=temp;
else
prev->add=temp;
prev=temp;
flushall();
y=getch();
}while(y=='y' || y=='Y');
return;
search()
int s;
int p=0;
int fl=0;
printf("Enter the info. to search..");
scanf("%d",&s);
prev=first;
do
p=p+1;
if(prev->info==s)
fl=1;
break;
else
prev=prev->add;
}while(prev!=NULL);
if(fl==1)
else
return;
disp()
clrscr();
prev=first;
printf("FIRST ->");
do
printf("%d ->",prev->info);
prev=prev->add;
}while(prev!=NULL);
printf("LAST");
return;
#include <stdio.h>
#include<conio.h>
#include<alloc.h>
#define NULL 0
struct node
int info;
};
NP *first,*temp,*prev,*last;
void main()
int x;
char c;
clrscr();
while(1)
printf("\n M E N U\n");
printf("*************\n\n");
printf("1.Creation.\n");
printf("2.Display.\n");
printf("3.Searching\n");
printf("4.Inserting\n");
printf("5.Deletion\n");
printf("6.Exit.\n\n");
scanf("%d",&x);
switch(x)
case 1:
crea();
break;
case 2:
disp();
break;
case 3:
search();
break;
case 4 :
ins();
break;
case 5:
dele();
break;
case 6:
exit();
ins()
int p;
int pos;
int i=0;
temp=NULL;
scanf("%d",&p);
temp->add=NULL;
scanf("%d",&temp->info);
switch(p)
case 1:
temp->add=first;
first=temp;
break;
case 2:
prev=first;
do
prev=prev->add;
}while(prev->add!=NULL);
prev->add=temp;
prev=temp;
break;
case 3:
scanf("%d",&pos);
prev=first;
while(i<pos-2)
i++;
prev=prev->add;
};
temp->add=prev->add;
prev->add=temp;
break;
return;
dele()
int ch;
int nn;
int i=1;
int ninfo;
printf("\nDELETION SUB-MENU\n");
printf("*****************\n\n");
scanf("%d",&ch);
switch(ch)
case 1:
first=first->add;
break;
case 2:
prev=first;
while(prev->add->add!=NULL)
prev=prev->add;
prev->add=NULL;
break;
case 3:
scanf("%d",&nn);
prev=first;
while(i<nn-1)
prev=prev->add;
i++;
prev->add=prev->add->add;
break;
case 4:
scanf("%d",&ninfo);
prev=first;
while(prev->add!=NULL)
if(prev->add->info==ninfo)
prev->add=prev->add->add;
break;
else
prev=prev->add;
break;
return;
crea()
char y;
do
{
scanf("%d",&temp->info);
if(first==NULL)
first=temp;
prev=temp;
else
prev->add=temp;
prev=temp;
flushall();
y=getch();
}while(y=='y' || y=='Y');
return;
search()
{
int s;
int p=0;
int fl=0;
scanf("%d",&s);
prev=first;
do
p=p+1;
if(prev->info==s)
fl=1;
break;
else
prev=prev->add;
}while(prev!=NULL);
if(fl==1)
}
else
return;
disp()
clrscr();
prev=first;
printf("FIRST ->");
do
printf("%d ->",prev->info);
prev=prev->add;
}while(prev!=NULL);
printf("LAST");
return;
#include<conio.h>
struct node
int info;
};
NP *first,*prev,*temp;
void main()
int x;
int pos;
clrscr();
while(1)
printf("\nMAIN MENU\n");
printf("**********\n\n");
printf("1.Creation\n");
printf("2.Display\n");
printf("3.Info Sum\n");
printf("4.Info. Avg.\n");
printf("5.Node Count.\n");
printf("6.Search Node.\n");
printf("7.Exit\n\n");
scanf("%d",&x);
switch(x)
case 1:
creat();
break;
case 2:
disp();
break;
case 3:
inf_sum();
break;
case 4:
inf_avg();
break;
case 5:
node_count();
break;
case 6:
if((pos=search_node())>0)
else
break;
case 7:
exit(1);
inf_sum()
int s=0;
prev=first;
while(prev->next!=NULL)
s=s+prev->info;
prev=prev->next;
inf_avg()
int s=0;
float a;
int cnt=1;
prev=first;
while(prev->next!=NULL)
s=s+prev->info;
prev=prev->next;
cnt++;
a=(float)s/cnt;
return;
node_count()
int i=1;
prev=first;
while(prev->next!=NULL)
i++;
prev=prev->next;
return;
search_node()
int s;
int i=1;
scanf("%d",&s);
prev=first;
while(prev->next!=NULL)
if(prev->info==s)
return i;
i++;
prev=prev->next;
return 0;
creat()
{
char y;
clrscr();
first=prev=temp=NULL;
do
temp=(NP*)malloc(sizeof(struct node));
temp ->next=NULL;
scanf("%d",&temp->info);
if (first==NULL)
first=temp;
prev=temp;
else
prev->next=temp;
prev=temp;
y=getch();
}while(y=='y'||y=='Y');
return;
disp()
{
clrscr();
prev=first;
printf("First : ");
while(prev!=NULL)
printf(" %d :",prev->info);
prev=prev->next;
printf(" Last");
return;