mercredi 12 mai 2021

How to store number of LinkedLists that the user enters at runtime? [closed]

I'm trying to solve a problem where I need to create my own Linked List data structure in C++ for a project.

So I created a basic struct:

struct Node
{
    int data;
    Node* next;
};

And I have a simple Push function to add more nodes into one List.

Everything works fine but at the start of the program the user has to enter a number (n) that will indicate how many Linked Lists the program has to make.

Now I tried creating a vector that can store the Lists but I had some problems with it.

Is there an easy way to implement this?

Some extra info (although not relevant with my problem but you never know) the data for each Node of the List will be a random number between [0, 250].

Sorry if the above doesn't make sense and thank you all for your time!

Aucun commentaire:

Enregistrer un commentaire