MCPcopy Create free account
hub / github.com/Ayush7614/Daily-Coding-DS-ALGO-Practice / main

Function main

Data Structures/QueueUsingLL.cpp:94–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92
93
94int main() {
95
96 Queue<int> q;
97
98 int choice;
99 cin >> choice;
100 int input;
101
102 while (choice !=-1) {
103 if(choice == 1) {
104 cin >> input;
105 q.enqueue(input);
106 }
107 else if(choice == 2) {
108 int ans = q.dequeue();
109 if(ans != 0) {
110 cout << ans << endl;
111 }
112 else {
113 cout << "-1" << endl;
114 }
115 }
116 else if(choice == 3) {
117 int ans = q.front();
118 if(ans != 0) {
119 cout << ans << endl;
120 }
121 else {
122 cout << "-1" << endl;
123 }
124 }
125 else if(choice == 4) {
126 cout << q.getSize() << endl;
127 }
128 else if(choice == 5) {
129 if(q.isEmpty()) {
130 cout << "true" << endl;
131 }
132 else {
133 cout << "false" << endl;
134 }
135 }
136 cin >> choice;
137 }
138
139}

Callers

nothing calls this directly

Calls 5

frontMethod · 0.80
getSizeMethod · 0.80
enqueueMethod · 0.45
dequeueMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected