//標頭檔案io流
#include
//標頭檔案檔案流
using namespace std;
//命名空間
#define error
0//巨集,作為錯誤返回
// 定義單鏈表
typedef struct lnode lnode,
*linklist;
//鍊錶變數lnode,鍊錶指標linklist
int num_a;
//la元素的個數
int num_b;
//lb元素的個數
int st =
'a';
//檔名
// 建立單鏈表
void
initlist_ll
(linklist &l)
// 依次向單鏈表l輸入對應的資料
void
linklist_input
(linklist &
l, int n)
; cout <<
"請輸入非遞減單向鍊錶"
<<
(char)st <<
"的資料檔案名稱(檔名+「.txt」,比如list"
<<
(char)st <<
".txt)"
<< endl;
++st;
gets_s
(filename)
;//獲取檔名
fstream file;
//檔案流
file.
open
(filename)
;//開啟檔案if(
!file)
//檔案開啟成功?
while
(!file.
eof())
file.
close()
;}// 輸出鍊錶的資料結點
void
output_ll
(linklist l)}
// 鏈式儲存結構有序表的合併
void
mergelinklist_ll
(linklist &
la, linklist &
lb, linklist &lc)
else
} pc-
>next = pa ? pa : pb;
// 插入非空表的剩餘段
deletelb;
}int main()
合併有序鍊錶C
author victor lv date 2016 9 1 11 20 description c list merge sort c 將兩個公升序排列的鍊錶合併成乙個公升序排列的鍊錶 不開闢新的鍊錶,直接將原鍊錶重新組合 輸入 兩個list的頭指標 返回 新的list頭指標 listnode f...
合併有序鍊錶C
author victor lv date 2016 9 1 11 20 description c list merge sort c 將兩個公升序排列的鍊錶合併成乙個公升序排列的鍊錶 不開闢新的鍊錶,直接將原鍊錶重新組合 輸入 兩個list的頭指標 返回 新的list頭指標 listnode f...
兩有序鍊錶的合併
已知兩個鍊錶head1和head2各自有序,請把它們合成乙個鍊錶依然有序。保留所有結點,即便大小相同 鍊錶節點結構 typedef struct node node 合併函式的介面為 node merge node head1,node head2 答 node merge node head1,n...