File tree Expand file tree Collapse file tree 1 file changed +11
-12
lines changed
Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -5,27 +5,26 @@ PLINKED_LIST
55Reverse (
66 _In_ PLINKED_LIST LinkedList )
77{
8- PLINKED_LIST pPrev , pCurrent , pTemp ;
8+ PLINKED_LIST Prev , Current , Next ;
99
10- /* Process the first node */
11- pPrev = LinkedList ;
12- pCurrent = pPrev -> Next ;
13- pPrev -> Next = NULL ;
10+ /* Preparation for the first node */
11+ Prev = NULL ;
12+ Current = LinkedList ;
1413
1514 /* Traversal the rest nodes */
16- while (pCurrent != NULL )
15+ while (Current != NULL )
1716 {
1817 /* Let current node points to the previous node */
19- pTemp = pCurrent -> Next ;
20- pCurrent -> Next = pPrev ;
18+ Next = Current -> Next ;
19+ Current -> Next = Prev ;
2120
2221 /* Move to the next node */
23- pPrev = pCurrent ;
24- pCurrent = pTemp ;
22+ Prev = Current ;
23+ Current = Next ;
2524 }
2625
2726 /* The last node is the head now */
28- return pPrev ;
27+ return Prev ;
2928}
3029
3130_Function_class_ (FN_EXAMPLE_PROC )
@@ -48,7 +47,7 @@ DataStructure_LinkedList_Reverse(void)
4847 return false;
4948 }
5049
51- /* Restore LinkedListA and return success */
50+ /* Restore LinkedListA */
5251 LinkedListA = Reverse (ReverseLinkedList );
5352
5453 /* Test LinkedListB, which has only one node */
You can’t perform that action at this time.
0 commit comments