Add example inputs
This commit is contained in:
36
examples/leap_year/leap_year.mc
Normal file
36
examples/leap_year/leap_year.mc
Normal file
@@ -0,0 +1,36 @@
|
||||
bool isLeapYear(int n)
|
||||
{
|
||||
if ((modulo(n,4) == 0 && modulo(n,100) != 0) || (modulo(n,400) == 0)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int modulo(int k, int i)
|
||||
{
|
||||
while (k > 0){
|
||||
k = k - i;
|
||||
}
|
||||
return k;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
print("Please enter a year: ");
|
||||
print_nl();
|
||||
|
||||
int n;
|
||||
n = read_int();
|
||||
|
||||
print_int(n);
|
||||
if (isLeapYear(n)){
|
||||
print(" is a leap year.");
|
||||
}
|
||||
else
|
||||
{
|
||||
print(" is not a leap year.");
|
||||
}
|
||||
print_nl();
|
||||
|
||||
return 0;
|
||||
}
|
1
examples/leap_year/leap_year.stdin.txt
Normal file
1
examples/leap_year/leap_year.stdin.txt
Normal file
@@ -0,0 +1 @@
|
||||
2020
|
2
examples/leap_year/leap_year.stdout.txt
Normal file
2
examples/leap_year/leap_year.stdout.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Please enter a year:
|
||||
2020 is a leap year.
|
Reference in New Issue
Block a user