It is necessary to write a program with lists of students, using list structures. Also in the program should be file input information about students search. Tell me where to start? Also, I can not understand what are generally linked lists. If possible, sample code. Thank.

  • look towards STL list - list container. <div> <a></a> </ div> - carapuz 5:46 pm
  • If more, then: you need to implement an information system that will support work with personal data of students (view, edit, search by name, add / delete), work with lists of groups (also add, delete, view) and file input / output about the flow. The program must have a menu system. - skies
  • "....-> prev = -> next; delete node; ... linked list on pointers" just so -_- help, who can do what) - skies
  • Singly connected or doubly connected? Or is it not important? - carapuz
  • Simply connected is better, I think. - skies

3 answers 3

Since the details of the task are not specified, I will give an answer from what is. In your case, the so-called maps from the Standard Template Library , namely the map\multimap containers, could be suitable. They are very convenient when a specific value is attached to one particular value. In your case it can be the Фамилия студента -> Курс , for example. But such a container cannot store duplicate keys, and you may need it if, for example, several values ​​are attached to a student's last name:

 [Фамилия] => [Курс] [Фамилия] => [Имя] [Фамилия] => [Возраст] 

In this case, the MultiMap container is just right. All STL containers support the search that you need and many other useful features. Basically, you should be aware of this.

As for the linked lists, I’ll say that it’s easy to implement on your own. The linked list has such a structure that each of its elements (except the last one) points to the next one after it + each element stores some useful information. The structure is somewhat similar to the structure of a binary tree, but the structure of the latter is somewhat more complicated. Here is an example.

  • five
    Something tells me that this study task does not imply either std::list<T> or std::map<T> , but is intended for the person to implement the classic ->prev = ->next; delete node; ... ->prev = ->next; delete node; ... ->prev = ->next; delete node; ... list on pointers. Although, of course, I could be wrong. - Costantino Rupert
  • one
    And minus for what? Justify, please, who put. - AseN 6:01 pm
  • @Asen, in your example it is very small, but by the type of structure you can guess that we are talking about a simply linked list. To remove biconnected more convenient. - avp 6:41 pm

You can start, I think, with the implementation of a template list for an abstract type T directly. In your case, you can create a structure that stores the names, ratings, and other information. We describe the list node:

 template <class T> class Node { private: T data; Node<T> *next, *prev; public: Node(Т); ~Node(); }; 

List class:

 template <class T> class List { private: Node<T> *Head, *Tail; public: List(); List(const List&); ~List(); void View(); void Clear(); void AddFirst(); void AddLast(); void WriteToFile(); void ReadFromFile(); ... }; 

Here, implement the functions you need to work: for example, adding to the beginning, to the end, to a certain position, deleting elements, viewing, reading / writing to a file, etc.

    what are generally linked lists. If possible, sample code.

    A manual to help you: the fundamental data structures that can be used as the basis for constructing abstract data representing real objects of the problem being solved .