Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. Node *add_first(Node *a, char* data)
  2. {
  3.     Node *c = (Node*)malloc(1 * sizeof(Node));
  4.     *c = { data, a };
  5.     return c;
  6. }
  7.  
  8. Node *reverse(Node* a)
  9. {
  10.     Node *b = a, *c = (Node*)malloc(1 * sizeof(Node));
  11.     *c = { a->data, NULL };
  12.     while (b->next != NULL)
  13.     {
  14.         b = b->next;
  15.         c = add_first(c, b->data);
  16.     }
  17.     return c;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement