aboutsummaryrefslogtreecommitdiff
path: root/DSAA/chap3_lists_stacks_queues/ex_3.c
diff options
context:
space:
mode:
authorSteve Lee <me@xiangyangli.com>2017-04-19 22:43:18 +0800
committerSteve Lee <me@xiangyangli.com>2017-04-19 22:43:18 +0800
commit9ee91c759c5a87030cebb6b79adc94230f23da4a (patch)
tree4184793354ac57cdbf7002e6821c301bc24ad44a /DSAA/chap3_lists_stacks_queues/ex_3.c
parentce07c94e0ec62a829e0d0c447ec4c932f0f78c3d (diff)
downloadPersonal-9ee91c759c5a87030cebb6b79adc94230f23da4a.tar.xz
Personal-9ee91c759c5a87030cebb6b79adc94230f23da4a.zip
remove
Diffstat (limited to 'DSAA/chap3_lists_stacks_queues/ex_3.c')
-rw-r--r--DSAA/chap3_lists_stacks_queues/ex_3.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/DSAA/chap3_lists_stacks_queues/ex_3.c b/DSAA/chap3_lists_stacks_queues/ex_3.c
new file mode 100644
index 0000000..6981ce9
--- /dev/null
+++ b/DSAA/chap3_lists_stacks_queues/ex_3.c
@@ -0,0 +1,45 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "list.h"
+
+void SwapSinglyAdjacentNode( Position FrontP, Position BackP , List L)
+{
+ Position TmpCell;
+
+ TmpCell = FindPrevious( FrontP->Element, L );
+ TmpCell->Next = BackP;
+
+ TmpCell = FrontP;
+ FrontP->Next = BackP->Next;
+ BackP->Next = TmpCell;
+}
+
+void SwapDoublyAdjacnetNode( Position P1, Position P2 )
+{
+
+}
+
+int main()
+{
+ List L;
+ Position Front, Back;
+
+ L = malloc( sizeof( struct Node ) );
+
+ Insert(1, L, L);
+ Insert(2, L, L);
+ Insert(3, L, L);
+ Insert(4, L, L);
+
+ PrintList( L );
+
+ Front = Find(3, L);
+ Back = Find(2, L);
+
+ SwapSinglyAdjacentNode(Front, Back, L);
+
+ PrintList( L );
+
+ return 0;
+}