Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
14
Task/User-input-Text/Ada/user-input-text-1.ada
Normal file
14
Task/User-input-Text/Ada/user-input-text-1.ada
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
function Get_String return String is
|
||||
Line : String (1 .. 1_000);
|
||||
Last : Natural;
|
||||
begin
|
||||
Get_Line (Line, Last);
|
||||
return Line (1 .. Last);
|
||||
end Get_String;
|
||||
|
||||
function Get_Integer return Integer is
|
||||
S : constant String := Get_String;
|
||||
begin
|
||||
return Integer'Value (S);
|
||||
-- may raise exception Constraint_Error if value entered is not a well-formed integer
|
||||
end Get_Integer;
|
||||
2
Task/User-input-Text/Ada/user-input-text-2.ada
Normal file
2
Task/User-input-Text/Ada/user-input-text-2.ada
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
My_String : String := Get_String;
|
||||
My_Integer : Integer := Get_Integer;
|
||||
15
Task/User-input-Text/Ada/user-input-text-3.ada
Normal file
15
Task/User-input-Text/Ada/user-input-text-3.ada
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
with Ada.Text_IO, Ada.Integer_Text_IO;
|
||||
|
||||
procedure User_Input is
|
||||
I : Integer;
|
||||
begin
|
||||
Ada.Text_IO.Put ("Enter a string: ");
|
||||
declare
|
||||
S : String := Ada.Text_IO.Get_Line;
|
||||
begin
|
||||
Ada.Text_IO.Put_Line (S);
|
||||
end;
|
||||
Ada.Text_IO.Put ("Enter an integer: ");
|
||||
Ada.Integer_Text_IO.Get(I);
|
||||
Ada.Text_IO.Put_Line (Integer'Image(I));
|
||||
end User_Input;
|
||||
18
Task/User-input-Text/Ada/user-input-text-4.ada
Normal file
18
Task/User-input-Text/Ada/user-input-text-4.ada
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
with
|
||||
Ada.Text_IO,
|
||||
Ada.Integer_Text_IO,
|
||||
Ada.Strings.Unbounded,
|
||||
Ada.Text_IO.Unbounded_IO;
|
||||
|
||||
procedure User_Input2 is
|
||||
S : Ada.Strings.Unbounded.Unbounded_String;
|
||||
I : Integer;
|
||||
begin
|
||||
Ada.Text_IO.Put("Enter a string: ");
|
||||
S := Ada.Strings.Unbounded.To_Unbounded_String(Ada.Text_IO.Get_Line);
|
||||
Ada.Text_IO.Put_Line(Ada.Strings.Unbounded.To_String(S));
|
||||
Ada.Text_IO.Unbounded_IO.Put_Line(S);
|
||||
Ada.Text_IO.Put("Enter an integer: ");
|
||||
Ada.Integer_Text_IO.Get(I);
|
||||
Ada.Text_IO.Put_Line(Integer'Image(I));
|
||||
end User_Input2;
|
||||
Loading…
Add table
Add a link
Reference in a new issue