Guest User

Untitled

a guest
Jun 6th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. /***************************/
  5. string nazev = "Pepa";
  6.  struct clovek {
  7.     string jmeno;
  8.     int telCislo;
  9. } ;
  10.  
  11. struct uzel {
  12.     uzel *dalsiUzel;
  13.     clovek human;
  14. };
  15. uzel *vrchol = NULL;
  16. /***************************/
  17. void zasobnik(string jmeno, int cislo){
  18.     if (vrchol == NULL){
  19.         cout<<"Vrchol zasobniku"<<endl;
  20.         vrchol = new uzel;
  21.         vrchol -> human.jmeno = jmeno;
  22.         vrchol -> human.telCislo = cislo;
  23.         vrchol -> dalsiUzel = NULL;
  24.         cout<<"Ulozil jsem do zasobniku hodnoty"<<endl;
  25.     } else {
  26.         cout<<"Vytvareni noveho uzlu"<<endl;
  27.         uzel *novyUzel = new uzel;
  28.         novyUzel -> human.jmeno = jmeno;
  29.         novyUzel -> human.telCislo = cislo;
  30.         vrchol = novyUzel;
  31.         cout<<"Novy uzel vytvoren - konec funkce"<<endl;
  32.     }
  33. }
  34. void vypisZasobniku(uzel *uzly){
  35.     while (uzly != NULL){
  36.         cout<<uzly -> human.jmeno<<endl;
  37.         cout<<uzly -> human.telCislo<<endl;
  38.         uzly = uzly -> dalsiUzel;
  39.     }
  40. }
  41. int main()
  42. {
  43.     for (int i = 0; i <= 5; i++){
  44.         zasobnik(nazev, 774587412);
  45.     }
  46.     for (int y = 0; y <= 5; y++){
  47.         cout<<"Vypisuji hodnotu ze zasobniku c."<< y<<endl;
  48.         vypisZasobniku(vrchol);
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment