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 .
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 :)
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: http://www.cplusplus.com/reference/stl/
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?