Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Типичный программист

a guest Nov 28th, 2014 27,237 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Node *copyList(Node *head)
  2. {
  3.   for (Node* cur = head; cur != NULL; cur = cur->next) {
  4.     Node* dup = (Node*)malloc(sizeof(Node));
  5.     dup->data = cur->data;
  6.     dup->next = cur->random;
  7.     cur->random = dup;
  8.   }
  9.   Node* result = head->random;
  10.   for (Node* cur = head; cur != NULL; cur = cur->next) {
  11.     Node* dup = cur->random;
  12.     dup->random = dup->next->random;
  13.   }
  14.   for (Node* cur = head; cur != NULL; cur = cur->next) {
  15.     Node* dup = cur->random;
  16.     cur->random = dup->next;
  17.     dup->next = cur->next ? cur->next->random : NULL;
  18.   }
  19.   return result;
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top