與本題類似的其它幾個題解答如下
() 解答完全同上
() 本題是求交集即只有同時出現在兩集合中的元素才出現在結果表中其核心語句段如下
pa=la>next;pb=lb>next;∥設工作指針pa和pb;
pc=la;∥結果表中當前合並結點的前驅的指針
while(pa&&pb)
if(pa>data==pb>data)∥交集並入結果表中
{ pc>next=pa;pc=pa;pa=pa>next;
u=pb;pb=pb>next;free(u);}
else if(pa>data<pb>data) {u=pa;pa=pa>next;free(u);}
else {u=pb; pb=pb>next; free(u);}
while(pa){ u=pa; pa=pa>next; free(u);}∥ 釋放結點空間
while(pb) {u=pb; pb=pb>next; free(u);}∥釋放結點空間
pc>next=null;∥置鏈表尾標記
free(lb);∥注 本算法中也可對B表不作釋放空間的處理
[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
From:http://tw.wingwit.com/Article/program/sjjg/201311/23356.html