user-0 提问: 一道华三笔试题， 100分求解！给出思路即可，有代码更好！

回复:
user: user-1
content: 使用排序插入，二分法查找位置，即插入后保证是按索引值排序的 对插入位置的断开链表，将新节点加人  分别对两个索引量执行相同的操作

user: user-2
content: 写了一个 ，不知道对不对。。。    typedef struct tagData  {  int index1;  int index2;  int iData;  struct tagData *pstNext1;  struct tagData *pstNext2;  }NODE_S;    #include <stdlib.h> #include <stdio.h> #include <string.h> #include "head.h" NODE_S *pHead1,*pHead2; //链表初始化 void init() { 	pHead1=(NODE_S*)malloc(sizeof(NODE_S)); 	memset(pHead1,0,sizeof(NODE_S)); 	pHead1->next1=NULL; 	pHead1->next2=NULL; 	pHead1->index1=0;  	pHead2=(NODE_S*)malloc(sizeof(NODE_S)); 	memset(pHead2,0,sizeof(NODE_S)); 	pHead2->next1=NULL; 	pHead2->next2=NULL; 	pHead2->index2=0; } void destory(NODE_S *Head,int iNum) { 	NODE_S *tHead=Head; 	if (1==iNum) 	{ 		Head=Head->next1; 	} 	else 	{ 		Head=Head->next2; 	} 	while ( Head->next1!=NULL ) 	{ 		free(tHead); 		tHead=Head; 		if (1==iNum ) 		{ 			Head=Head->next1; 		} 		else 		{ 			Head=Head->next2; 		} 	} 	tHead=NULL; } //节点插入 void Add(int index1,int index2,int iData) { 	//排序插入pHead1; 	NODE_S *tHead1,*tHead2,*tNode1,*tNode2; 	int Count=0; 	tHead1=pHead1; 	tHead2=pHead2; 	if (0==tHead1->index1) 	{ 		tHead1->iData=iData; 		tHead1->index1=index1; 		tHead1->index2=index2; 		tHead1->next2=NULL; 		tHead1->next1=NULL; 	} 	else 	{ 		if (tHead1->index1>index1) 		{ 			tNode1=(NODE_S*)malloc(sizeof(NODE_S)); 			tNode1->iData=iData; 			tNode1->index1=index1; 			tNode1->next1=tHead1; 			tNode1->index2=index2; 			tNode1->next2=NULL; 			pHead1=tNode1; 		} 		else 		{ 			while (tHead1->next1!=NULL &&index1>=tHead1->next1->index1 ) 			{ 				tHead1=tHead1->next1; 			} 			tNode1=(NODE_S*)malloc(sizeof(NODE_S)); 			tNode1->iData=iData; 			tNode1->index1=index1;  			tNode1->next1=tHead1->next1; 			tHead1->next1=tNode1; 			tNode1->next2=NULL; 			tNode1->index2=index2; 		} 		 	} 	 	if (0==tHead2->index2) 	{ 		tHead2->iData=iData; 		tHead2->index2=index2; 		tHead2->index1=index1; 		tHead2->next1=NULL; 		tHead2->next2=NULL; 	} 	else 	{ 		if (tHead2->index2>index2) 		{ 			tNode2=(NODE_S*)malloc(sizeof(NODE_S)); 			tNode2->iData=iData; 			tNode2->index2=index2; 			tNode2->next2=tHead2; 			tNode2->index1=index1; 			tNode2->next1=NULL; 			pHead2=tNode2; 		} 		else 		{ 			while ( tHead2->next2!=NULL && index2>=tHead2->next2->index2) 			{ 				tHead2=tHead2->next2; 			} 			tNode2=(NODE_S*)malloc(sizeof(NODE_S)); 			tNode2->iData=iData; 			tNode2->index2=index2;  			tNode2->next2=tHead2->next2; 			tHead2->next2=tNode2; 			tNode2->next1=NULL; 			tNode2->index1=index1; 		} 		 	} } void ShowList(NODE_S* pHead,int iNum) { 	NODE_S *tHead=pHead; 	while (NULL!=tHead) 	{ 		if (1==iNum) 		{ 			//printf(" %d-%d ",tHead->iData,tHead->index1); 			printf(" %d ",tHead->index1); 			tHead=tHead->next1; 		} 		else 		{ 			//printf(" %d-%d ",tHead->iData,tHead->index2); 			printf(" %d ",tHead->index2); 			tHead=tHead->next2; 		}	 	} } void Delete(int index2) { 	NODE_S *tHead1=pHead1->next1,*tHead2=pHead2->next2; 	NODE_S *f_tHead1=pHead1,*f_tHead2=pHead2; 	int count=0; 	if (tHead1->index2==index2) 	{ 		free(pHead1); 		pHead1=tHead1; 	} 	if (tHead2->index2==index2) 	{ 		free(pHead2); 		pHead2=tHead2; 	} 	while (tHead1!=NULL &&tHead1->index2!=index2) 	{ 		f_tHead1=tHead1; 		tHead1=tHead1->next1; 	} 	while (tHead2!=NULL && tHead2->index2!=index2) 	{ 		f_tHead2=tHead2; 		tHead2=tHead2->next2; 	} 	if (tHead1!=NULL) 	{ 		f_tHead1->next1=tHead1->next1; 		free(tHead1); 		count++; 	} 	if (tHead2!=NULL) 	{ 		f_tHead2->next2=tHead2->next2; 		free(tHead2); 		count++; 	} 	if (count==2)//去除重复节点 	{ 		Delete(index2); 	} } int main(int argc,char *argv[]) { 	init(); 	Add(5,5,10); 	Add(2,2,11); 	Add(4,4,12); 	Add(6,9,13); 	Add(3,1,14); 	Add(8,5,15); 	Add(99,8,16); 	Add(6,3,17); 	ShowList(pHead1,1); 	printf("\n\n"); 	ShowList(pHead2,2); 	printf("\n\n"); 	Delete(5); 	ShowList(pHead1,1); 	printf("\n\n"); 	ShowList(pHead2,2); 	destory(pHead1,1); 	destory(pHead2,2); 	return 0; }

user: user-3
content: 看来我的理解能力真差

user: user-2
content: void add(int index1,int index2,int iData);  这个里面 的 index1和index2 是插入链表的索引哦？