מיזוג בפסקל.
עשיתי פונקציה למיזוג בפסקל. ומשום מה היא לא עובדת. מישהו יכול להצביע למה?
עשיתי פונקציה למיזוג בפסקל. ומשום מה היא לא עובדת. מישהו יכול להצביע למה?
procedure merging(var T:arr1; var T2:arr2; var T3:arr3); var p1,p2,p3:integer; begin p1:=1; p2:=1; p3:=1; while (p3<=len3) and (p2<=len2) and (p1<=len1) do begin if t[p1] < t2[p2] then begin t3[p3] := t[p1]; p1:=p1+1; end else if t[p1] > t2[p2] then begin t3[p3] := t2[p2]; p2:=p2+1; end else begin t3[p3] := t[p1]; p1:=p1+1; end; end; if not(p1 = len1) then while (p3<=len3) and (p1<=len1) do begin t3[p3]:=t[p1]; p1:=p1+1; p3:=p3+1; end else while (p3<=len3) and (p2<=len2) do begin t3[p3]:=t2[p2]; p2:=p2+1; p3:=p3+1 end; end;
t,t2,t3 הם מערכים שהוכנסו בפרוצדורות אחרות. ו len1-3 הם האורכים שלהם