尝试运行此程序时出现错误:
引发 CONSTRAINT_ERROR:bifid.adb:55 索引检查失败
我不确定这个错误来自哪里或它的确切含义。有问题的行是
End_String := End_String & Get_Character(
S, Ind(Count*(length(Cipher_Text))/2), Ind(Count));
任何帮助将不胜感激。我正在使用 Ada 95 和 GNAT 编译器。
function Decipher(S : Square; Cipher_Text : Ustring) return Ustring is
type IndArray is array(1..(length(Cipher_Text)*2)) of Integer;
Ind : IndArray;
Temp : Character;
Row : Integer;
Col : Integer;
Count : Integer := 1;
End_String : Ustring;
begin
Ind := (others=>0);
for I in 1..length(Cipher_Text) loop
Temp := Uppercase(Element(Cipher_Text, I));
if In_Square(S, Temp) then
Get_Coordinates(S, Temp, Row, Col);
Ind(I) := row;
Ind(I + length(Cipher_Text)) := Col;
end if;
end loop;
while Count <= length(Cipher_Text)*2 loop
End_String := End_String & Get_Character(
S, Ind(Count*(length(Cipher_Text))/2), Ind(Count));
Count := Count + 2;
end loop;
return End_String;
end Decipher;