A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/d3/dfb/circular__queue__using__array_8cpp_source.html below:

TheAlgorithms/C++: operations_on_datastructures/circular_queue_using_array.cpp Source File

Loading...

Searching...

No Matches

circular_queue_using_array.cpp

1#include <iostream> 2using

std::cin;

3using

std::cout;

4 5int queue

[10];

6int

front = 0;

7int

rear = 0;

8int

count = 0;

9 10void

Enque(

int

x) {

11 if

(count == 10) {

12

cout <<

"\nOverflow"

;

13

}

else

{

14 queue

[rear] = x;

15

rear = (rear + 1) % 10;

16

count++;

17

}

18

}

19 20void

Deque() {

21 if

(front == rear) {

22

cout <<

"\nUnderflow"

;

23

}

24 25 else

{

26

cout <<

"\n"

<<

queue

[front] <<

" deleted"

;

27

front = (front + 1) % 10;

28

count--;

29

}

30

}

31 32void

show() {

33 for

(

int

i = 0; i < count; i++) {

34

cout <<

queue

[(i + front) % 10] <<

"\t"

;

35

}

36

}

37 38int main

() {

39 int

ch, x;

40 do

{

41

cout <<

"\n1. Enque"

;

42

cout <<

"\n2. Deque"

;

43

cout <<

"\n3. Print"

;

44

cout <<

"\nEnter Your Choice : "

;

45

cin >> ch;

46 if

(ch == 1) {

47

cout <<

"\nInsert : "

;

48

cin >> x;

49

Enque(x);

50

}

else if

(ch == 2) {

51

Deque();

52

}

else if

(ch == 3) {

53

show();

54

}

55

}

while

(ch != 0);

56 57 return

0;

58

}

queue Definition queue.hpp:9 main

int main()

Main function.

Definition generate_parentheses.cpp:110

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4