为什么会出现此错误?
“ ADA.FLOAT_IO”不是预定义的库单元
我以前从未在ADA中写过任何东西,只是我不知道自己在做什么。我使用GNAT进行编译。
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Float_IO; use Ada.Float_IO;
with Ada.Numerics.Elementary_Functions;
use Ada.Numerics.Elementary_Functions;
procedure MAIN is
A,B,C:Float;
W : Float;
Re, Im:Float;
begin
Put("Give A");Get(A);
Put("Give B");Get(B);
Put("Give C");Get(C);New_Line;
if A=0.0 then
Put_Line("It is not second degree polynomial");
else
W:=B*B - 4.0*A*C;
Re:=B/(2.0*A); Im:=Sqrt(Abs(W))/(2.0*A);
Put("dif = "); Put(W);New_Line;
if W<0.0 then
Put_Line("Complex ");
Put("x1 = ");Put(-Re);Put(" -j ");Put(Im);Put(" ");
Put("x2 = ");Put(-Re);Put(" +j ");Put(Im);New_Line;
else
Put_Line("Real");
Put("x1 = ");Put(-Re-Im);Put(" ");
Put("x2 = ");Put(-Re+Im);
end if;
end if;
end MAIN;
Run Code Online (Sandbox Code Playgroud)
IIRC Float_IO是个孩子Text_IO:Ada.Text_IO.Float_IO。此外,这是一个通用程序包。我猜你想Ada.Float_Text_IO,它被定义为
package Ada.Float_Text_IO is new Ada.Text_IO.Float_IO (Float);
Run Code Online (Sandbox Code Playgroud)