Cpp Program to Reverse a List using Data Swapping
#include <bits/stdc++.h> NEW_LINE using namespace std ; struct Node { int data ; struct Node * prev , * next ; } ; Node * newNode ( int val ) { Node * temp = new Node ; temp -> data = val ; temp -> prev = temp -> next = nullptr ; return temp ; } void printList ( Node * head ) { while ( head -> next != nullptr ) { cout << head -> data << " ▁ < - - > ▁ " ; head = head -> next ; } cout << head -> data << endl ; }