Click here to Skip to main content
15,902,299 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Question"WMVideo9 Encoder DMO" Filter Pin
Andy Rama5-Apr-06 23:40
Andy Rama5-Apr-06 23:40 
Question"WMVideo9 Encoder DMO" Filter Pin
Andy Rama5-Apr-06 23:39
Andy Rama5-Apr-06 23:39 
QuestionWindows Socket Problem Pin
QuickDeveloper5-Apr-06 23:22
QuickDeveloper5-Apr-06 23:22 
AnswerRe: Windows Socket Problem Pin
Ștefan-Mihai MOGA6-Apr-06 0:57
professionalȘtefan-Mihai MOGA6-Apr-06 0:57 
AnswerRe: Windows Socket Problem Pin
abbiyr6-Apr-06 5:34
abbiyr6-Apr-06 5:34 
Questionlinker error for ScriptStringAnalyse ??? Pin
jayart5-Apr-06 23:14
jayart5-Apr-06 23:14 
QuestionQueue and Stacks Pin
KOOOSHA5-Apr-06 23:05
KOOOSHA5-Apr-06 23:05 
AnswerRe: Queue and Stacks Pin
parichaybp5-Apr-06 23:11
parichaybp5-Apr-06 23:11 
Hi ,

I have sent u Queue implemented using linked list. hope it will be helpfull for u.



#include<stdio.h>
struct node
{
int data;
struct node *link;
};

void insert_rear(struct node **,int);
int delete_front(struct node **);
void display(struct node *);
int count(struct node **);

main()
{
int size,k,ch,n;
struct node *p;
clrscr();
p=NULL;
printf("Enter the max size of the queue : ");
scanf("%d",&size);
while(1)
{
printf("\n\n1 to insert item in the queue");
printf("\n2 to delete item in the queue");
printf("\n3 to display elements of the queue");
printf("\n4 to count number of elements in the queue");
printf("\n0 to exit : \n");
printf("\nEnter ur choice : ");
scanf("%d",&ch);
switch(ch)
{
case 1:
if(count(&p)==size) {
printf("\nQueue full\n");
break;
}
else {
printf("enter the data to be inserted in the queue ");
scanf("%d",&n);
insert_rear(&p,n);
printf("item %d inserted in queue",n);
}
break;
case 2:
if(count(&p)==0) {
printf("queue empty");
break;
}
else {
k=delete_front(&p);
printf("deleted item from queue is %d",k);
}
break;
case 3:
printf("the values in the queue are\n");
display(p);
break;
case 4:
printf("the total number of elements in the queue are %d",count(&p));
break;
case 0:
exit(0);
default:
printf("wrong choice");
}
}
}

void insert_rear(struct node **q,int num)
{
struct node *temp,*r;
temp=*q;
if(temp==NULL)
{
temp=(struct node *)malloc(sizeof(struct node));
temp->data=num;
temp->link=NULL;
*q=temp;
}
else
{
while(temp->link!=NULL)
temp=temp->link;
r=(struct node *)malloc(sizeof(struct node));
r->data=num;
r->link=NULL;
temp->link=r;
}
}

int delete_front(struct node **q)
{
int k;
struct node *temp;
temp=*q;
k=temp->data;
*q=temp->link;
free(temp);
return k;
}

void display(struct node *q)
{
while(q!=NULL)
{
printf("%d\t",q->data);
q=q->link;
}
}

int count(struct node **q)
{
int c=0;
struct node *temp;
temp=*q;
while(temp!=NULL)
{
c++;
temp=temp->link;
}
return c;
}
AnswerRe: Queue and Stacks Pin
toxcct5-Apr-06 23:21
toxcct5-Apr-06 23:21 
AnswerRe: Queue and Stacks Pin
Cedric Moonen5-Apr-06 23:32
Cedric Moonen5-Apr-06 23:32 
GeneralRe: Queue and Stacks Pin
toxcct5-Apr-06 23:33
toxcct5-Apr-06 23:33 
AnswerRe: Queue and Stacks Pin
Bob Stanneveld5-Apr-06 23:43
Bob Stanneveld5-Apr-06 23:43 
GeneralRe: Queue and Stacks Pin
Eytukan5-Apr-06 23:45
Eytukan5-Apr-06 23:45 
JokeRe: Queue and Stacks Pin
toxcct5-Apr-06 23:46
toxcct5-Apr-06 23:46 
GeneralRe: Queue and Stacks Pin
Bob Stanneveld5-Apr-06 23:48
Bob Stanneveld5-Apr-06 23:48 
JokeRe: Queue and Stacks Pin
toxcct5-Apr-06 23:50
toxcct5-Apr-06 23:50 
JokeRe: Queue and Stacks Pin
Bob Stanneveld5-Apr-06 23:53
Bob Stanneveld5-Apr-06 23:53 
AnswerRe: Queue and Stacks Pin
Stephen Hewitt6-Apr-06 0:56
Stephen Hewitt6-Apr-06 0:56 
GeneralRe: Queue and Stacks Pin
toxcct6-Apr-06 1:03
toxcct6-Apr-06 1:03 
GeneralRe: Queue and Stacks Pin
Sebastian Schneider6-Apr-06 2:19
Sebastian Schneider6-Apr-06 2:19 
GeneralRe: Queue and Stacks Pin
toxcct6-Apr-06 2:29
toxcct6-Apr-06 2:29 
GeneralRe: Queue and Stacks Pin
KOOOSHA6-Apr-06 4:40
KOOOSHA6-Apr-06 4:40 
GeneralRe: Queue and Stacks Pin
Stephen Hewitt6-Apr-06 14:08
Stephen Hewitt6-Apr-06 14:08 
QuestionRe: Queue and Stacks Pin
David Crow6-Apr-06 3:05
David Crow6-Apr-06 3:05 
AnswerRe: Queue and Stacks Pin
KOOOSHA6-Apr-06 4:34
KOOOSHA6-Apr-06 4:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.