June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
30
Task/Leap-year/Modula-2/leap-year.mod2
Normal file
30
Task/Leap-year/Modula-2/leap-year.mod2
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
MODULE LeapYear;
|
||||
FROM FormatString IMPORT FormatString;
|
||||
FROM Terminal IMPORT WriteString,ReadChar;
|
||||
|
||||
PROCEDURE IsLeapYear(year : INTEGER) : BOOLEAN;
|
||||
BEGIN
|
||||
IF year MOD 100 = 0 THEN
|
||||
RETURN year MOD 400 = 0;
|
||||
END;
|
||||
RETURN year MOD 4 = 0
|
||||
END IsLeapYear;
|
||||
|
||||
PROCEDURE Print(year : INTEGER);
|
||||
VAR
|
||||
buf : ARRAY[0..63] OF CHAR;
|
||||
leap : BOOLEAN;
|
||||
BEGIN
|
||||
leap := IsLeapYear(year);
|
||||
FormatString("Is %i a leap year? %b\n", buf, year, leap);
|
||||
WriteString(buf)
|
||||
END Print;
|
||||
|
||||
BEGIN
|
||||
Print(1900);
|
||||
Print(1994);
|
||||
Print(1996);
|
||||
Print(1997);
|
||||
Print(2000);
|
||||
ReadChar
|
||||
END LeapYear.
|
||||
Loading…
Add table
Add a link
Reference in a new issue