Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <stdio.h>
  3. #include <iostream>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. struct Item
  9. {
  10.     char part[20];
  11.     Item *next;
  12. };
  13.  
  14. typedef Item* Point;
  15.  
  16. void Create(Point &Head)
  17. {
  18.     Point P, Last = NULL;
  19.     char ch;
  20.  
  21.     cout << "Vuvedi element? ";
  22.     cin >> ch;
  23.  
  24.     while (ch == 'Y' || ch == 'y')
  25.     {
  26.         P = new Item;
  27.         cin >> P->part;
  28.         P->next = NULL;
  29.  
  30.         if (Head == NULL)
  31.         {
  32.             Head = P;
  33.         }
  34.         else
  35.         {
  36.             Last->next = P;
  37.         }
  38.         Last = P;
  39.  
  40.         cout << "Vuvedi element? ";
  41.         cin >> ch;
  42.     }
  43. }
  44.  
  45. void PrintElements(Point P, char *word)
  46. {
  47.     while (P)
  48.     {
  49.         cout << P->part << word;
  50.         P = P->next;
  51.     }
  52. }
  53.  
  54. void main()
  55. {
  56.     Point Head = NULL;
  57.     Create(Head);
  58.  
  59.     char keyword[20];
  60.     cout << "Vuvedete kodova duma: ";
  61.     cin >> keyword;
  62.  
  63.     PrintElements(Head, keyword);
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement