June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
45
Task/Nth/Modula-2/nth.mod2
Normal file
45
Task/Nth/Modula-2/nth.mod2
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
MODULE Nth;
|
||||
|
||||
FROM STextIO IMPORT
|
||||
WriteString, WriteLn;
|
||||
FROM WholeStr IMPORT
|
||||
IntToStr;
|
||||
|
||||
PROCEDURE Suffix(N: CARDINAL; VAR OUT Destination: ARRAY OF CHAR);
|
||||
VAR
|
||||
NMod10, NMod100: CARDINAL;
|
||||
BEGIN
|
||||
NMod10 := N MOD 10;
|
||||
NMod100 := N MOD 100;
|
||||
IF (NMod10 = 1) AND (NMod100 <> 11) THEN
|
||||
Destination := "st";
|
||||
ELSIF (NMod10 = 2) AND (NMod100 <> 12) THEN
|
||||
Destination := "nd";
|
||||
ELSIF (NMod10 = 3) AND (NMod100 <> 13) THEN
|
||||
Destination := "rd";
|
||||
ELSE
|
||||
Destination := "th";
|
||||
END;
|
||||
END Suffix;
|
||||
|
||||
PROCEDURE PrintImages(LoLim, HiLim: CARDINAL);
|
||||
VAR
|
||||
I: CARDINAL;
|
||||
IString: ARRAY [0 .. 15] OF CHAR;
|
||||
ISuff: ARRAY [0 .. 1] OF CHAR;
|
||||
BEGIN
|
||||
FOR I := LoLim TO HiLim DO
|
||||
IntToStr(I, IString);
|
||||
Suffix(I, ISuff);
|
||||
WriteString(IString);
|
||||
WriteString(ISuff);
|
||||
WriteString(" ");
|
||||
END;
|
||||
WriteLn;
|
||||
END PrintImages;
|
||||
|
||||
BEGIN
|
||||
PrintImages( 0, 25);
|
||||
PrintImages( 250, 265);
|
||||
PrintImages(1000, 1025);
|
||||
END Nth.
|
||||
Loading…
Add table
Add a link
Reference in a new issue