March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
8
Task/Leap-year/AutoHotkey/leap-year-1.ahk
Normal file
8
Task/Leap-year/AutoHotkey/leap-year-1.ahk
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
leapyear(year)
|
||||
{
|
||||
if (Mod(year, 100) = 0)
|
||||
return (Mod(year, 400) = 0)
|
||||
return (Mod(year, 4) = 0)
|
||||
}
|
||||
|
||||
MsgBox, % leapyear(1604)
|
||||
6
Task/Leap-year/AutoHotkey/leap-year-2.ahk
Normal file
6
Task/Leap-year/AutoHotkey/leap-year-2.ahk
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
IsLeapYear(Year)
|
||||
{
|
||||
return !Mod(Year, 4) && Mod(Year, 100) || !Mod(Year, 400)
|
||||
}
|
||||
|
||||
MsgBox % "The year 1604 was " (IsLeapYear(1604) ? "" : "not ") "a leap year"
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
MsgBox % "The year 1600 was " . (IsLeapYear(1600) ? "" : "not ") . "a leap year"
|
||||
|
||||
IsLeapYear(Year)
|
||||
{
|
||||
Return, !Mod(Year, 100) && !Mod(Year, 400) && !Mod(Year, 4)
|
||||
}
|
||||
5
Task/Leap-year/Julia/leap-year.julia
Normal file
5
Task/Leap-year/Julia/leap-year.julia
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
leap(y) = y%4==0 && (y<1582 || y%400==0 || y%100!=0)
|
||||
|
||||
# some tests
|
||||
@assert all([leap(yr) for yr in [2400, 2012, 2000, 1600, 1500, 1400]])
|
||||
@assert all([~leap(yr) for yr in [2100, 2014, 1900, 1800, 1700, 1499]])
|
||||
4
Task/Leap-year/Mercury/leap-year-1.mercury
Normal file
4
Task/Leap-year/Mercury/leap-year-1.mercury
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
:- pred is_leap_year(int::in) is semidet.
|
||||
|
||||
is_leap_year(Year) :-
|
||||
( if Year mod 100 = 0 then Year mod 400 = 0 else Year mod 4 = 0 ).
|
||||
18
Task/Leap-year/Mercury/leap-year-2.mercury
Normal file
18
Task/Leap-year/Mercury/leap-year-2.mercury
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
:- module leap_year.
|
||||
:- interface.
|
||||
|
||||
:- import_module io.
|
||||
:- pred main(io::di, io::uo) is det.
|
||||
|
||||
:- implementation.
|
||||
:- import_module int, list, string.
|
||||
|
||||
main(!IO) :-
|
||||
Years = [1600, 1700, 1899, 1900, 2000, 2006, 2012],
|
||||
io.write_list(Years, "", write_year_kind, !IO).
|
||||
|
||||
:- pred write_year_kind(int::in, io::di, io::uo) is det.
|
||||
|
||||
write_year_kind(Year, !IO) :-
|
||||
io.format("%d %s a leap year.\n",
|
||||
[i(Year), s(if is_leap_year(Year) then "is" else "is not" )], !IO).
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
sub leap {
|
||||
my $yr = $_[0];
|
||||
if ($yr % 100 == 0) {
|
||||
return ($yr % 400 == 0);
|
||||
sub isleap {
|
||||
my $year = shift;
|
||||
if ($year % 100 == 0) {
|
||||
return ($year % 400 == 0);
|
||||
}
|
||||
return ($yr % 4 == 0);
|
||||
return ($year % 4 == 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
sub leap {!($_[0] % 100) ? !($_[0] % 400) : !($_[0] % 4)}
|
||||
sub isleap { !($_[0] % 100) ? !($_[0] % 400) : !($_[0] % 4) }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
use Date::Manip;
|
||||
Date_LeapYear($year);
|
||||
print Date_LeapYear(2000);
|
||||
|
||||
use Date::Manip::Base;
|
||||
my $dmb = new Date::Manip::Base;
|
||||
$dmb->leapyear($year);
|
||||
print $dmb->leapyear(2000);
|
||||
|
||||
use DateTime;
|
||||
my $date = DateTime->new(year => 2000);
|
||||
print $date->is_leap_year();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue