http://kmlinux/~culik/wiki #include "stdafx.h" #include using namespace std; struct item { string name; string number; item * prev; item * next; }; struct queue { item * first; item * last; }; queue list; void init () { list.first = nullptr; list.last = nullptr; } void add (string id, string num) { item * t = new item; t->name = id; t->number = num; t->prev = list.last; t->next = nullptr; if (list.first == nullptr) list.first = t; else list.last->next = t; list.last = t; } void insert (string id, string num) { item* _it = list.first; while(_it != nullptr && _it->name < id) _it = _it->next; if(_it == nullptr) add(id, num); else if(_it->name == id) _it->number=num; else { item * t = new item; t->name = id; t->number = num; t->prev = _it-> prev; t->next = _it; _it ->prev = t; if (t->prev==nullptr) list.first = t; else t->prev->next = t; } } int _tmain (int argc, _TCHAR* argv[]) { init (); insert ("Martin", "777852694"); insert ("Pepa", "722456802"); insert ("Jarda", "603782694"); cout << "Seznam: " << endl; item * t = list.first; while (t != nullptr) { cout << "Cislo: " << t->number.c_str() << ", Jmeno: " << t->name.c_str() << endl; t = t->next; } cout << "Konec - stisknete enter" << endl; char c; cin >> c; return 0; }