queues

This is a discussion on queues within the C++ Programming forums, part of the General Programming Boards category; pls help me it is so urgent ı need short examples with queues, it is so important me pls send ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    4

    queues

    pls help me it is so urgent
    ı need short examples with queues,
    it is so important me pls send there small exercises that done with queue
    thanks so much everyone

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Google?

    Edit: You could have at least checked out this site, btw....

    http://www.cprogramming.com/tutorial...ory/queue.html

    That contains a link to a code example.

  3. #3
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,479
    Google: "Queue exercises in C++"
    I'm just trying to be a better person - My Name Is Earl

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    4
    pls sned ı search all interenet but cant find if u have queue examples send

  5. #5
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Try clicking the link?

  6. #6
    Registered User
    Join Date
    Dec 2007
    Posts
    4
    just one example and no more pls interest this topic

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Code:
    int main()
    {
       Queue.insert(1);
       Queue.insert(2);
       cout << Queue.get();
       cout << Queue.get();
       return 0;
    }
    There you go, that's an example of a using a queue.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Does anyone think this will do?

    Code:
    template <typename T> 
    class q {
     private:
      class p {
      public:
        p() : n(0) {};
        T d;
        p *n;
      };
      p *h, *t;
     public:
      q<T>(): h(0), t(0) {};
      
        void insert(T x) { 
          t = (t)?(t->n=new p):(h = t = new p);
          t->d = x;
        };
      bool get(T &x) { 
        p* p = h; if (!p) return false; 
        x = p->d; h = (p == t)? t = p->n : p->n;
        delete p; 
        return true;
      };
    };

    On the obfuscation: I'm sure I could make get use another terniary operator for the return value, but I guess it's close enough as it is...

    --
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    Registered User
    Join Date
    Dec 2007
    Posts
    4
    pls help me more complex examples nuone doesnt know about queue?

  10. #10
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,830
    I've just been shopping, and there are plenty of queues at the checkouts.

    There's even an "8 items or less" express checkout.

    Write a simulation modelling the movement of people through a store checkout, where
    - number of items
    - number of distracting / yelling kids
    - number of money off coupons
    - method of payment (cash, cheque, card)
    All affect how fast an individual person makes it through the checkout.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Concatenating two static queues?
    By difficult.name in forum C Programming
    Replies: 2
    Last Post: 10-19-2004, 12:19 AM
  2. stacks and queues
    By j0hnb in forum C Programming
    Replies: 4
    Last Post: 04-16-2003, 10:44 PM
  3. help with queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-21-2002, 10:09 PM
  4. queues
    By jamesb in forum C Programming
    Replies: 1
    Last Post: 04-21-2002, 09:57 PM
  5. queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 10-11-2001, 06:19 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21