一、去除单链表中的重复结点
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
//删除单链表中的重复结点
typedef struct LNode //单链表结点定义
{
int data;
LNode *next;
}LNode;
//创建一个单链表结点
void CreateLNode(LNode *&L)
{
L=(LNode*)malloc(sizeof(LNode));
L->next=NULL;
}
//为单链表添加一个结点
void InputLNodeList(LNode *&L,int d)
{
LNode *c,*s;
c=L->next;
CreateLNode(s);
s->data=d;
L->next=s;
s->next=c;
c=s;
}
//打印单链表
void ShowList(LNode *L)
{
LNode *c;
c=L->next;
printf("打印单链表:");
while(c!=NULL)
{
printf("%d\t",c->data);
c=c->next;
}
printf("\n");
}
//去除重复单链表中的重复结点
void DeleteSameNode(LNode *&L)
{
LNode *pre,*c,*s;
pre=L->next;
c=L->next;
s=L;
while(pre!=NULL)
{
while(c!=NULL)
{
if(c->data==pre->data)
{
s->next=