Page 1 of 2 12 LastLast
Results 1 to 20 of 29

Thread: C++ Experts?

  1. #1
    Marcello's Avatar
    Join Date
    03 Dec 05
    Posts
    4,735
    Thanked
    66 times
    Fav. Player
    J.Cesar

    Australia

    10 years of FIF

    C++ Experts?

    Hi everyone , this forums is huge and i need some help , does anyone know anything to do with Stacks and linked lists/arrays?

    lol this is a bit random but am very desperate

    Thankyou

    Forza Inter!

  2. #2
    king_elnino's Avatar
    Join Date
    06 Jul 11
    Posts
    1,442
    Thanked
    482 times
    Fav. Player
    Javier Zanetti

    Indonesia

    give your code here, i'll see what can i do for you
    Ti Te Dominet Milan

    Quote Originally Posted by gazzetta dello sport
    "Injustice came immediately but they did not turn it into an excuse. Instead, Inter raised up to control the game at the home of the then unbeatable Juventus. Shining and mastery."

  3. Thanks (1): Marcello

  4. #3
    Fitzy's Avatar
    Join Date
    21 Aug 09
    Posts
    9,945
    Thanked
    15,553 times
    Fav. Player
    Zanetti

    Australia

    Forum Supporter
    What are you stuck with?

  5. Thanks (1): Marcello

  6. #4
    Marcello's Avatar
    Join Date
    03 Dec 05
    Posts
    4,735
    Thanked
    66 times
    Fav. Player
    J.Cesar

    Australia

    10 years of FIF
    wow that was quick responses thanyou ok so heres the problem , ill need help on the code but the problem is the worst part

    well theres a problem to the question i have, i need to implement it with stacks (push,pop,top)

    but this is the idea it is


    [URL=http://imageshack.us/photo/my-images/833/plajm.jpg/]

  7. #5
    Pajo's Avatar
    Join Date
    08 Apr 06
    Posts
    35,934
    Thanked
    20,800 times
    Fav. Player
    Sergio Aguero!

    Macedonia

    10 years of FIF
    Why do people still use C++ for lists and arrays...? Java is the language for that, no pointers (well everything IS pointer, but you dont specify it). It's much easier to use Java for this job than c++...
    "This wonderful night will give us the colours for our crest: black and blue against a backdrop of gold stars. It will be called Internazionale, because we are brothers of the world."

    Derby d'Italia, why the rivalry?
    My message to JuBe cunts

  8. #6
    Marcello's Avatar
    Join Date
    03 Dec 05
    Posts
    4,735
    Thanked
    66 times
    Fav. Player
    J.Cesar

    Australia

    10 years of FIF
    Quote Originally Posted by Pajo View Post
    Why do people still use C++ for lists and arrays...? Java is the language for that, no pointers (well everything IS pointer, but you dont specify it). It's much easier to use Java for this job than c++...
    pajoo!!!!

    im just a bigginer mate , ill work my way up to java once i can get through this.. i hate pointers lol

    ---------- Post added at 21:29 ---------- Previous post was at 21:26 ----------


    • The Train can drive in or out of “(T1),(T2)” Forward or Backwards
    • The Train can be disconnected between 2 “Cargos”
    • A cargo can be parked temporally in (T1),(T2) , but not on the main track!
    • A cargo cannot move without the engine

  9. #7
    Pajo's Avatar
    Join Date
    08 Apr 06
    Posts
    35,934
    Thanked
    20,800 times
    Fav. Player
    Sergio Aguero!

    Macedonia

    10 years of FIF
    That's the thing, you dont NEED to learn C++ to learn java. It's better for understanding lists though.

    And you, i was wondering if you are alive. Where the fuck have you been?

    As for the problem, i havent touched c++ for over 3 years, so i can hardly be of any help. Sry I could explain what i'd do, but cant give you the code. Maybe elnino or fitzy can
    "This wonderful night will give us the colours for our crest: black and blue against a backdrop of gold stars. It will be called Internazionale, because we are brothers of the world."

    Derby d'Italia, why the rivalry?
    My message to JuBe cunts

  10. #8
    Marcello's Avatar
    Join Date
    03 Dec 05
    Posts
    4,735
    Thanked
    66 times
    Fav. Player
    J.Cesar

    Australia

    10 years of FIF
    Quote Originally Posted by Pajo View Post
    That's the thing, you dont NEED to learn C++ to learn java. It's better for understanding lists though.

    And you, i was wondering if you are alive. Where the fuck have you been?

    As for the problem, i havent touched c++ for over 3 years, so i can hardly be of any help. Sry I could explain what i'd do, but cant give you the code. Maybe elnino or fitzy can
    lol your funy man , iv been here just not signed in lol thanks for asking


    aww comon pajo help me bro.. can i use a vector & stack would that be easier


    i just have to get 5 numbers randomly 4,3,5,1,2 , doesnt matter how they are numbered , and they have to go into 2 junctions (t1,t2) to get sorted using stacks when they come out of the junction they must be re ordered to 1,2,3,4,5

    simple ?

  11. #9
    8|G 8055 blackmore's Avatar
    Join Date
    15 Sep 04
    Posts
    14,622
    Thanked
    2,393 times
    Fav. Player
    SE SALTELLI....

    Singapore

    why take the train, when u can fly?

    Ma Milanista Che cazzo canti, Nella tua testa I ricordi sono tanti,
    Ci ricordate, del sei a zero, Ma gia' scordate Serie B e Totonero,
    Percio' ricorda, nella tua testa, quando eri in B tutta la nord faceva festa,
    Tifoso pirla, ma chi minacci? Altro che curva, siete un gruppo di palliaci.

    E Milan merda, Milan, Milan merda, E Milan merda, Milan, Milan merda.



    BRING BACK LELE

  12. #10
    Pajo's Avatar
    Join Date
    08 Apr 06
    Posts
    35,934
    Thanked
    20,800 times
    Fav. Player
    Sergio Aguero!

    Macedonia

    10 years of FIF
    Yeah. The main tracks should be implemented with double linked lists, i think it is the best. The t1 and t2 with stacks. If the train is parked, and another comes in, i guess the second that came must get out first, and than the other, that;s the stack.

    What is the engine actually, some value? If so, than the "train" must start with that value, which will represent the engine. For disconnecting trains, you will need a function that separates one big list in two or more smaller ones. As for the aprking, i have no idea how to make it
    "This wonderful night will give us the colours for our crest: black and blue against a backdrop of gold stars. It will be called Internazionale, because we are brothers of the world."

    Derby d'Italia, why the rivalry?
    My message to JuBe cunts

  13. Thanks (1): Marcello

  14. #11
    La Brujita's Avatar
    Join Date
    17 May 07
    Posts
    2,592
    Thanked
    569 times
    Fav. Player
    J.Zanetti

    Saudi Arabia

    42 Forum Supporter
    I haven't done proper programming in quite a while now

    Just some websites.

    I remember a bit about linked lists and stacks. I can't remember well, if no one comes to help I'll try and help but you can also post in websites like stackoverflow to get good answers for these questions

  15. Thanks (1): Marcello

  16. #12
    Marcello's Avatar
    Join Date
    03 Dec 05
    Posts
    4,735
    Thanked
    66 times
    Fav. Player
    J.Cesar

    Australia

    10 years of FIF
    Quote Originally Posted by Pajo View Post
    Yeah. The main tracks should be implemented with double linked lists, i think it is the best. The t1 and t2 with stacks. If the train is parked, and another comes in, i guess the second that came must get out first, and than the other, that;s the stack.

    What is the engine actually, some value? If so, than the "train" must start with that value, which will represent the engine. For disconnecting trains, you will need a function that separates one big list in two or more smaller ones. As for the aprking, i have no idea how to make it

    I have only done linked lists and arrays based stacks

    but theres only one train and 2 stacks, and the engine can move backwards and forwards , pretty much the engine is what makes the stack work and the engine always has to be in front , so i dont know how the hell im going to code that , wow this is so hard

  17. #13
    king_elnino's Avatar
    Join Date
    06 Jul 11
    Posts
    1,442
    Thanked
    482 times
    Fav. Player
    Javier Zanetti

    Indonesia

    You need pointer to solve next and back..
    Ti Te Dominet Milan

    Quote Originally Posted by gazzetta dello sport
    "Injustice came immediately but they did not turn it into an excuse. Instead, Inter raised up to control the game at the home of the then unbeatable Juventus. Shining and mastery."

  18. Thanks (1): Marcello

  19. #14
    Marcello's Avatar
    Join Date
    03 Dec 05
    Posts
    4,735
    Thanked
    66 times
    Fav. Player
    J.Cesar

    Australia

    10 years of FIF
    ok , so would code like this be good for my problem?
    or maybe not?


    Code:
    // This program demonstrates the DynIntQeue class.
    #include <iostream>
    #ifndef DYNINTQUEUE_H
    #define DYNINTQUEUE_H
    using namespace std;
    
    ////////////////////////////////////////////////////////////////////////
    class DynIntQueue
    {
    private:
       // Structure for the queue nodes
       struct QueueNode
       {
          int value;       // Value in a node
          QueueNode *next; // Pointer to the next node
       };
       QueueNode *front;  // The front of the queue
       QueueNode *rear;   // The rear of the queue
       int numItems;      // Number of items in the queue 
    public:
       // Constructor
       DynIntQueue();
       // Destructor
       ~DynIntQueue();
       // Queue operations
       void enqueue(int);
       void dequeue(int &);
       bool isEmpty() const;
       bool isFull() const;
       void clear();
    };
    ////////////////////////////////////////////////////////////////////////
     
    
    //**************************************************
    // Destructor                                      *
    // This function deletes every node in the list.   *
    //**************************************************
     DynIntStack::~DynIntStack()
    {
       StackNode *nodePtr, *nextNode;
       // Position nodePtr at the top of the stack.
       nodePtr = top;
       // Traverse the list deleting each node.
       while (nodePtr != NULL)
       {
          nextNode = nodePtr->next;
          delete nodePtr;
          nodePtr = nextNode;
       }
    }
    //************************************************
    // Member function push pushes the argument onto *
    // the stack.                                    *
    //************************************************
    void DynIntStack::push(int num)
    {
       StackNode *newNode; // Pointer to a new node
       // Allocate a new node and store num there.
       newNode = new StackNode;
       newNode->value = num;
       // If there are no nodes in the list
       // make newNode the first node.
       if (isEmpty())
       {
          top = newNode;
          newNode->next = NULL;
       }
       else  // Otherwise, insert NewNode before top.
       {
          newNode->next = top;
          top = newNode;
       }
    }
    //****************************************************
    // Member function pop pops the value at the top     *
    // of the stack off, and copies it into the variable *
    // passed as an argument.                            *
    //****************************************************
    void DynIntStack::pop(int &num)
    {
       StackNode *temp; // Temporary pointer
       // First make sure the stack isn't empty.
       if (isEmpty())
       {
          cout << "The stack is empty.\n";
       }
       else  // pop value off top of stack
       {
          num = top->value;
          temp = top->next;
          delete top;
          top = temp;
       }
    }
    //****************************************************
    // Member function isEmpty returns true if the stack *
    // is empty, or false otherwise.                     *
    //****************************************************
    bool DynIntStack::isEmpty()
    {
       bool status;
       if (!top)
          status = true;
       else
          status = false;
       return status;
    }
    ///////////////////////////////////////////////////////////////////////////////
     
     
    int main()
    {
       const int MAX_VALUES = 5;
       // Create a DynIntQueue object.
       DynIntQueue iQueue;
       // Enqueue a series of numbers.
       cout << "Enqueuing " << MAX_VALUES << " items...\n";
       for (int x = 0; x < 5; x++)
          iQueue.enqueue(x);
       
       // Dequeue and retrieve all numbers in the queue
       cout << "The values in the queue were:\n";
       while (!iQueue.isEmpty())
       {
          int value;
          iQueue.dequeue(value);
          cout << value << endl;
       }
       system("pause");
       return 0;
    }


    ---------- Post added at 17:17 ---------- Previous post was at 17:16 ----------

    Also i cant even get that above code to work ^

  20. #15
    Marcello's Avatar
    Join Date
    03 Dec 05
    Posts
    4,735
    Thanked
    66 times
    Fav. Player
    J.Cesar

    Australia

    10 years of FIF
    Quote Originally Posted by Pajo View Post
    Yeah. The main tracks should be implemented with double linked lists, i think it is the best. The t1 and t2 with stacks. If the train is parked, and another comes in, i guess the second that came must get out first, and than the other, that;s the stack.

    What is the engine actually, some value? If so, than the "train" must start with that value, which will represent the engine. For disconnecting trains, you will need a function that separates one big list in two or more smaller ones. As for the aprking, i have no idea how to make it
    aww thanks man

    theres only 1 train so just a single linked list? and ye the engine must be there , it must be the engine to collect the values in the stacks and move them from one to the other


    would you know how to code the stacks ? for 2 stacks? thats the hard part for me

  21. #16
    Pajo's Avatar
    Join Date
    08 Apr 06
    Posts
    35,934
    Thanked
    20,800 times
    Fav. Player
    Sergio Aguero!

    Macedonia

    10 years of FIF
    I told you, didnt work c++ for long long time, and never using stacks on it Not lists as well, never learned pointers like i should lol

    As for the train.. Hmm, yeah, you could use linked list only. I told you double linked because i thought the train could move both ways, didnt see that there is "entrance" and "exit". So yeah, SLL would be ok.
    "This wonderful night will give us the colours for our crest: black and blue against a backdrop of gold stars. It will be called Internazionale, because we are brothers of the world."

    Derby d'Italia, why the rivalry?
    My message to JuBe cunts

  22. Thanks (1): Marcello

  23. #17
    Marcello's Avatar
    Join Date
    03 Dec 05
    Posts
    4,735
    Thanked
    66 times
    Fav. Player
    J.Cesar

    Australia

    10 years of FIF
    anybody know anything about binary trees ?

  24. #18
    Pajo's Avatar
    Join Date
    08 Apr 06
    Posts
    35,934
    Thanked
    20,800 times
    Fav. Player
    Sergio Aguero!

    Macedonia

    10 years of FIF
    In Java yes, in c++, not really
    "This wonderful night will give us the colours for our crest: black and blue against a backdrop of gold stars. It will be called Internazionale, because we are brothers of the world."

    Derby d'Italia, why the rivalry?
    My message to JuBe cunts

  25. #19
    Marcello's Avatar
    Join Date
    03 Dec 05
    Posts
    4,735
    Thanked
    66 times
    Fav. Player
    J.Cesar

    Australia

    10 years of FIF
    Quote Originally Posted by Pajo View Post
    In Java yes, in c++, not really

    nawwwwww lol i need to make a binary tree for a menu .. sounds easy ehh

  26. #20
    Pajo's Avatar
    Join Date
    08 Apr 06
    Posts
    35,934
    Thanked
    20,800 times
    Fav. Player
    Sergio Aguero!

    Macedonia

    10 years of FIF
    I cant do it because its done with pointers in c++, i think. And i have never learned those pointers when i should have. In hava pointers are not needed, they are implemented in everything.. So, i cant help you
    "This wonderful night will give us the colours for our crest: black and blue against a backdrop of gold stars. It will be called Internazionale, because we are brothers of the world."

    Derby d'Italia, why the rivalry?
    My message to JuBe cunts

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •