Jump to content

Kernighans large earthquake problem: Difference between revisions

Added XPL0 example.
No edit summary
(Added XPL0 example.)
Line 1,799:
8/27/1883 Krakatoa 8.8
5/18/1980 MountStHelens 7.6
</pre>
 
=={{header|XPL0}}==
Usage: quake <data.txt
<lang XPL0>int C;
[loop [OpenO(8); \get line from input file
repeat C:= ChIn(1);
ChOut(8, C); \save it in buffer device 8
if C = $1A\EOF\ then quit;
until C = $0A\LF\;
OpenI(8);
repeat C:= ChIn(8); \skip to whitespace
until C <= $20\space\;
repeat C:= ChIn(8); \skip whitespace
until C > $20\space\;
repeat C:= ChIn(8); \skip to whitespace
until C <= $20\space\;
if RlIn(8) > 6.0 then
[OpenI(8); \output saved line to console
repeat C:= ChIn(8);
ChOut(0, C);
until C = $0A\LF\;
];
];
]</lang>
 
{{out}}
<pre>
8/27/1883 Krakatoa 8.8
5/18/1980 MountStHelens 7.6
1/25/4567 EdgeCase3 6.1
 
for data.txt
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>
 
772

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.