Guest User

Untitled

a guest
May 16th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct A
  6. {
  7. int cyfra;
  8. char symbol;
  9. };
  10.  
  11. struct List
  12. {
  13. A a;
  14. List* next;
  15. };
  16.  
  17. List * get_AList_item() {
  18. List *elem = new List;
  19.  
  20. if (cin >> elem->a.cyfra >> elem->a.symbol)
  21. return elem;
  22.  
  23. return 0;
  24. }
  25.  
  26. List *get_list() {
  27. List *head = get_AList_item(),
  28. *tail = head;
  29. while ((tail->next = get_AList_item()))
  30. tail = tail->next;
  31.  
  32. return head;
  33. }
  34.  
  35. int main() {
  36. // Получить заполненный список
  37. List *list = get_list();
  38.  
  39. // поэлементно распечатать его
  40. cout << "List:n";
  41. for (List *p = list; p; p = p->next)
  42. cout << p->a.cyfra << p->a.symbol << ' ';
  43. }
Add Comment
Please, Sign In to add comment