Wednesday, June 18, 2014

/ / Push - put on top of stack void stack :: push (int iNum) {element * new; new = new element; new


Hello, I need help from the tank. I have a LIFO stack's fixed and I would like it converted to FIFO, but have no idea how. If I understand correctly, that would be enough to revamp the push or pop method, right? (Both methods example). Could anyone help me how to do it?
/ / Push - put on top of stack void stack :: push (int iNum) {element * new; new = new element; new-> load (iNum, first); prvy = new; } / / Pop - choose from the top of stack void stack :: pop () {if (prvy! = NULL) {int iNum; * UK element; uk = First; iNum = uk-> list (); if (uk-> kontrola_adresy ()) {cout << uk-> list (); prvy = uk-> address babylon (); } If ((uk-> kontrola_adresy () == false) && (iNum! babylon = 0)) {prvy = NULL; }} Else {cout << "no element to delete" << endl; Thank you}}. Samsung printer ETARGET
of these two functions absolutely do not know how you got it implemented inside ... unless you have implemented as a linked list (preferred method) ... the FIFO need to store the location of the last element, ie from one side to the list adds up to the other party withdraws from the list (it's up to you whether you add to the end and take a start or add to the top and take in the end) .. important question would be: why implementing it yourself .. if you use C + + is better to use templates stack and queue in STL ? _________________ ~ Listen to your brain, not your heart ~ NB1: Lenovo Y500: CPU: Intel Core i7-3630QM; GPU: nVidia GT650M 2 gigabytes SLi; RAM 16GB DDR3; HDD: 1TB SSD + 256 gigabytes (m4); LCD: 15.6 "1920x1080 OS: Win8.1 64-bit + Arch Linux 64-bit (UEFI Powered DualBoot) NB2: Asus K53SJ-SX093: CPU: Intel Core i3-2310M, GPU: Intel HD3000 / Nvidia GT520M 1 gigabyte Optimus; RAM: 8 GB DDR3, HDD 1TB, LCD: 15.6 "1366x768; OS: Win7 Pro 64-bit N + Xubuntu 4.13 64-bit babylon crki76
Queue my header looks like this: # pragma once # include "stdafx.h" babylon # include "MyStack.h" # include "Queue.h" # include <stddef.h> template <class ItemType> struct babylon NodeType; template <class ItemType> QueType class {public: QueType (); ~ QueType (); MakeEmpty void (); bool IsEmpty () const; IsFull bool () const; void Enqueue (ItemType newItem); void Dequeue (ItemType & item); PrintQueue void (); private: NodeType * <ItemType> qFront; NodeType <ItemType> * qRear; }; template <class ItemType> QueType <ItemType> :: QueType () {qFront = NULL; qRear = NULL; ItemType>} template <class QueType <ItemType> :: ~ QueType () {MakeEmpty (); ItemType>} template <class void QueType <ItemType> :: MakeEmpty () {NodeType * <ItemType> tempPtr; while (qFront! = NULL) {tempPtr = qFront; qFront = qFront-> next; delete tempPtr; babylon QRear} = NULL; ItemType>} template <class bool QueType <ItemType> :: IsFull () const {NodeType <ItemType> * ptr; ptr = new NodeType <ItemType>; if (ptr == NULL) return true; else {delete ptr; return false; }} Template <class ItemType> babylon QueType <ItemType> :: bool IsEmpty () const {return (qFront babylon == NULL); ItemType>} template <class void QueType <ItemType> :: Enqueue (ItemType newItem) babylon {NodeType * <ItemType> newnode; newnode = new NodeType <ItemType>; newnode-> info = newItem; newnode-> next = NULL; if (qRear == NULL) qFront = newnode; else

No comments:

Post a Comment