#include "stdafx.h" #include #include using namespace std; struct item { string key; string val; item *next; }; item *first; item *last; item* find(string k){ item* p = first; while(p != NULL && p->key!=k) { p = p->next; } return p; } void list(){ item* p = first; cout << "Reading list." << endl; while(p != NULL) { cout << p->key << " , " << p->val << endl; p = p->next; } } void insertFirst(string k, string v){ item* p = new item; p->key = k; p->val = v; p->next = nullptr; if (last == nullptr) last = p; else p->next = first; first = p; } void insertLast(string k, string v){ item* p = new item; p->key = k; p->val = v; p->next = nullptr; if (first != nullptr) { last->next = p; last = p; } else { first = p; last = p; } } int _tmain(int argc, _TCHAR* argv[]) { cout << "Hello" << endl; first = NULL; last = nullptr; list(); insertLast("petr", "1"); list(); insertLast("pavel", "2"); list(); search ("jan"); search ("pavel"); search ("petr"); search ("vaclav"); system ("pause"); return 0; }