Kernighans large earthquake problem: Difference between revisions

no edit summary
(Add APL)
No edit summary
Line 124:
1/25/4567 EdgeCase3 6.1
</pre>
 
=={{header|Ada}}==
<lang Ada>-- Kernighans large earthquake problem
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
use Ada.Strings;
 
procedure Main is
Inpt_File : File_Type;
Space : Natural;
begin
Open (File => Inpt_File, Mode => In_File, Name => "data.txt");
while not End_Of_File (Inpt_File) loop
declare
Line : String :=
Trim (Source => Get_Line (File => Inpt_File), Side => Both);
begin
 
if Line'Length > 0 then
Space := Line'Last;
loop
exit when Line (Space) = ' ' or else Space = 0;
Space := Space - 1;
end loop;
 
if Space > 0 then
if Float'Value (Line (Space .. Line'Last)) > 6.0 then
Put_Line (Line);
end if;
end if;
end if;
end;
end loop;
Close (Inpt_File);
end Main;</lang>
The file data.txt contains a 0 length line as well as a line composed of only blanks.
<pre>
8/27/1883 Krakatoa 8.8
5/18/1980 MountStHelens 7.6
3/13/2009 CostaRica 5.1
1/23/4567 EdgeCase1 6
 
1/24/4567 EdgeCase2 6.0
1/25/4567 EdgeCase3 6.1
</pre>
{{output}}
<pre>
8/27/1883 Krakatoa 8.8
5/18/1980 MountStHelens 7.6
1/25/4567 EdgeCase3 6.1
</pre>
 
 
=={{header|ALGOL 68}}==
82

edits