在这个总结中,完成了大部分常用的单链表操作,如删除、插入结点,排序、逆序链表,约瑟夫问题等。约瑟夫问题的高效实现与分析参考其他经典算法,(从略)。
实现源代码如下:
// LinkListUD.cpp : Defines the entry point for the console application.
   //
   
   //—–header files
   
   #include “stdafx.h”
   
   #include <stdlib.h>
   
   #include <stdio.h>
   
   #include <iostream.h>
   
   #include <windows.h>
   
   //—–type definition
   
   typedef int ElemType;
   
   //—–global variables in this files
   
   //—–Linklist NODE
   
   typedef struct LNode
   
   {
   
   
   
   ElemType date;
   
   
   
   struct LNode *next;
   
   }linklist,*link;
   
   //————————-统计链表长度:即结点个数——————-
   
   int Length(link pHead,BOOL bTypeofLinkList)
   
   {
   
   
   
   if(pHead==NULL)
   
  
 
版权声明:本文为wyxblog原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。