#include "stdafx.h"
#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
typedef int type;
typedef struct lnode //定义链表结点的数据结构
{
int data;
struct lnode *next;
}Lnode;
typedef Lnode node;
typedef struct dnode//定义双链表结点的数据结构
{
int data;
struct dnode *lnext;
struct dnode *rnext;
}Dnode;
node *searchsamenode8(node *h1, node *h2)
{
int m, n; m = n = 0;
node *p1, *p2; p1 = h1->next; p2 = h2->next;
while (p1->next != NULL)
m++;
while (p2->next != NULL)
n++;
if (m == 0 || n == 0)
return NULL;
if (m >= n)
{
m -= n;
p1 = h1->next;
while (m-->0)
p1 = p1->next;
}
else
{
n -= m;
p2 = h2->next;
while (n-->0)
p1 = p1->next;
}
if (p1 == p2) return p1;
else if (p1 == p2 == NULL) return NULL;
else
{
p1 = p1->next;
p2 = p2->next;
}