fork download
  1. function queue:
  2. head = new node
  3. last = NULL
  4. choice = input()
  5. if choice == "enq", then:
  6. num = input()
  7. enqueue(num)
  8. else if choice == "deq", then:
  9. dequeue()
  10. else:
  11. quit()
  12.  
  13. function enqueue(n):
  14. p = new node
  15. p.value = n
  16. p.next = NULL
  17. if last != NULL, then:
  18. last.next = p;
  19. else:
  20. head.next = p;
  21. last = p
  22.  
  23. function dequeue:
  24. print head.next.value
  25. head.next = head.next.next
  26. if head.next = NULL, then:
  27. last = NULL
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty