Wirte a function that find the n biggest element from the list .Put these elements in an array in descending order . (You can run the list only once) .
I am a beginner , can someone guide me to solve this problem ? I haven't understood list really well .
We can't give you full programs for your assignments, but as for help, you know how arrays work, right? You need to know this to write the program.

Well, just an example array of type int is int MyArray[];.
To define arrays... just look in the tutorial:

You can access each element of the array separately and change their values if needed.

Use a for loop to process every element in the array.
Thank you :)
Yes i know haw arrays work and i have done in this way , but i want to know how i can do another way . I mean not to work with the array but just with list :)
I doubt there is such a thing as list.
If you want something else than arrays, look at vectors.
closed account (N85iE3v7)
Perhaps you meant STL list
I dont know how to write the code :/ I dont know because i dont understand list can u help me please ?
Where are you getting the list from, is the user inputting it or what?
Yes it is the user input
If you mean a linked list then it is a container with a similar use for an array.

A container is a way of storing data ( look at stacks, queues, binary trees etc) that also provides functions for handling/using that data.

Whereas normal arrays use contiguous memory blocks a linked list doesn't have such a restriction. Instead they use templated "nodes" to store the data which point to the next node in this list (or both ways). This property means they overcome a big drawback of normal arrays by being able to re-size the list. To do so with an array requires a lot of iterations and copying (slow). To do so with a linked list just means re linking the nodes to encompass the new one.

There is a lot more information in the link posted by zlogdan and more general information about containers if you want to decide if you need a list or a different container here:

However if you can solve the problem using just normal arrays then they are quicker than containers.
Make a limit to the number of items there can be in the list by either making a set number of cin<< commands, or make a counter that adds to a variable called numberofitems or something so you know how many items there are, and create a loop that goes through the items in the list (assigned to indexes in an array) and assigns item[1] to "int highest" then asks if item[2] is larger, if so it assigns int 2 to "highest" and so on. With me so far?
Topic archived. No new replies allowed.