兩個有序鍊錶序列的合併

2021-08-16 21:41:46 字數 798 閱讀 6175

3

1 3 5

52 4 6 8 10

1 2 3 4 5 6 8 10 

null

null

#include #include typedef int elementtype;  

typedef struct node *ptrtonode;

struct node ;

typedef ptrtonode list;

list read(); /* 細節在此不表 (也就是說提交的時候可以不考慮,不過還是要寫的!) */

void print( list l ); /* 細節在此不表;空煉表將輸出null (同上)*/

list merge( list l1, list l2 );

int main()

/* 你的**將被嵌在這裡 */

list read()

r->next=null;

} return l;

}void print(list l)

}else

printf("null");

printf("\n");

}list merge(list l1,list l2)

else

} p3->next=p2?p2:p1;

l1->next=null;

l2->next=null;

return l;

}

合併兩個有序鍊錶序列

本題要求實現乙個函式,將兩個鍊錶表示的遞增整數序列合併為乙個非遞減的整數序列。list merge list l1,list l2 其中list結構定義如下 typedef struct node ptrtonode struct node typedef ptrtonode list 定義單鏈表型...

兩個有序鍊錶序列的合併

習題2.5 兩個有序鍊錶序列的合併 15分 本題要求實現乙個函式,將兩個鍊錶表示的遞增整數序列合併為乙個非遞減的整數序列。list merge list l1,list l2 其中list結構定義如下 typedef struct node ptrtonode struct node typedef...

兩個有序鍊錶序列的合併

已知兩個非降序鍊錶序列s1與s2,設計函式構造出s1與s2的並集新非降序鍊錶s3。輸入分兩行,分別在每行給出由若干個正整數構成的非降序序列,用 表示序列的結尾 不屬於這個序列 數字用空格間隔。在一行中輸出合併後新的非降序鍊錶,數字間用空格分開,結尾不能有多餘空格 若新鍊錶為空,輸出null。1 3 ...