73 lines
1.6 KiB
Plaintext
73 lines
1.6 KiB
Plaintext
with Ada.Text_IO;
|
|
with Ada.Command_Line;
|
|
with Ada.Strings.Fixed;
|
|
with Ada.Integer_Text_IO;
|
|
|
|
procedure cl4 is
|
|
|
|
package T_IO renames Ada.Text_IO;
|
|
package CL renames Ada.Command_Line;
|
|
package S renames Ada.Strings;
|
|
package SF renames Ada.Strings.Fixed;
|
|
package I_IO renames Ada.Integer_Text_IO;
|
|
|
|
function GetLine (length: Integer := 1000) return String is
|
|
Line: String(1 .. length);
|
|
Last: Integer;
|
|
begin
|
|
T_IO.Get_Line(Line, Last);
|
|
return Line(1 .. Last);
|
|
end GetLine;
|
|
|
|
PartsLength : constant := 100;
|
|
|
|
X : String (1..1000);
|
|
Pos : Integer;
|
|
Part1, Part2: String (1 .. PartsLength);
|
|
Val1, Val2: Integer;
|
|
begin
|
|
|
|
T_IO.Put_Line("Próba wczytania tekstu ;)");
|
|
|
|
ReadingLines:
|
|
loop
|
|
SF.Move(
|
|
GetLine,
|
|
X,
|
|
S.Right,
|
|
S.Left,
|
|
Character'Val(0));
|
|
|
|
T_IO.Put_Line ("Wczytano: '" & X & "'");
|
|
|
|
Pos := SF.Index(
|
|
X,
|
|
" ");
|
|
|
|
T_IO.Put_Line ("Przerwe znaleziono na miejscu: " & Integer'Image(Pos));
|
|
|
|
SF.Move(
|
|
X(1..Pos-1),
|
|
Part1,
|
|
S.Right,
|
|
S.Left,
|
|
Character'Val(0));
|
|
|
|
SF.Move(
|
|
X(Pos+1 .. X'Last),
|
|
Part2,
|
|
S.Right,
|
|
S.Left,
|
|
Character'Val(0));
|
|
|
|
T_IO.Put_Line ("1. Czesc: '" & Part1(1..Pos-1) & "', 2. Czesc: '" & Part2(1..X'last-Pos-1) & "'");
|
|
|
|
Val1 := Integer'Value(Part1(1..Pos-1));
|
|
Val2 := Integer'Value(Part2(1..X'last-Pos-1));
|
|
|
|
exit ReadingLines when T_IO.End_Of_File;
|
|
|
|
end loop ReadingLines;
|
|
|
|
end cl4;
|