+ 2

Queue operations in c

In this code when I enter 2 and then 4 as operations,I should get "QUEUE:empty" as output but I am getting "QUEUE:4" https://code.sololearn.com/cmn2791CcY93/?ref=app

21st Aug 2018, 11:21 PM
harshit
harshit - avatar
2 Antworten
+ 9
Pretty sure line 87: if((front && rear)==-1) should be if(front==-1 && rear==-1)
22nd Aug 2018, 12:53 AM
Hatsy Rei
Hatsy Rei - avatar
+ 2
actually it should be if((front==-1 && rear==-1) || (front > rear)) You have to compare front and rear each time because you don't reset them immediately after front + 1.
22nd Aug 2018, 3:20 AM
Sergey Ushakov
Sergey Ushakov - avatar