Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
arraywithqueue
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x64 #include<stdio.h> #include<conio.h> #define size 5 int queue[size],choice,front=-1,rear=-1,value; void enqueue(); void dequeue(); void display(); void main() { printf("\n press 1 for enqueue \n press 2 for dequeue \n press 3 display \n press 4 for exit"); printf("\n enter your choice"); scanf("%d",&choice); do { switch(choice) { case 1: enqueue(); break; case 2: dequeue(); break; case 3: display(); break; default: printf("wrong choice"); } } while(1); getch(); } void enqueue() { if(rear=size-1) { printf("Queue is full"); } else { rear=rear+1; printf("\n Enter an value"); scanf("%d",&value); queue[rear]=value; } } void dequeue() { if(front==-1 && rear==-1) { printf("queue is empty"); } else { front=front+1; printf("%d",queue[front]); if(front==rear) { front=-1;rear=-1; } } } void display() { int i; for(i=front;i<=rear;i++) { printf("\n %d",queue[i]); } }
run
|
edit
|
history
|
help
0
BPC UDP pr3 cv10 final
pokus
hrátky s ukazately ++ bonusy ++ profi swap
struktura vzalenost
bignum test
test
makro vzdálenost
Empty struct
TStack_array
scanf.c