.ads内容:
generic
type Item is private;
type Index is (<>) ;
type Table_Array is array (Index range <>) of Item;
with function "<" (A, B: Item) return Boolean is <> ;
procedure TableSort ( T : in out Table_Array ) ;
所以这是我的插入排序代码:
procedure TableSort ( T: in out Table_Array) is
x : Item ;
j: Index;
begin
for I in T'Range loop
if T(Index'Succ(I)) < T(I) then
x := T(I) ;
T(I) := T(Index'Succ(I));
j := Index'Pred(Index'Pred(I));
while j <= T'First and x < T(Index'succ(j)) loop
T(j) := T(Index'Succ(j)) ;
j := Index'Pred(j);
end loop ;
T(Index'Pred(I)) := x ;
end if ;
end loop;
end TableSort ;
问题在于j := Index'Pred(Index'Pred(I));
。
它不接受它,我不知道如何使它工作。我的伙伴完成了,他把它分成了几块。还有其他想法吗?