1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| Status Merge_SqList(SqList LA, SqList LB, SqList &LC){ Init_SqList(LC); int i = j = 1, k = 0; if(LA.Length == 0 && LB.Length == 0) return ERROR; while(i <= LA.Length && j <= LB.Length){ GetElem(LA, i, ea); GetElem(LB, j, eb); if(ea <= eb) { Insert_SqList(LC, k++, ea); i++; }else{ Insert_SqList(LC, k++, eb); j++; } } while(i <= LA.Length){ GetElem(LA, i++, ea); Insert_SqList(LC, k++, ea); } while(j <= LB.Length){ GetElem(LB, i++, eb); Insert_SqList(LC, k++, eb); } return OK; }
|