Untitled
unknown
plain_text
a year ago
786 B
12
Indexable
#include <iostream>
using namespace std;
int main() {
int year;
// Input the year
cin >> year;
// Check if it's a leap year
if (year % 4 == 0) {
// If it's a century year, it must be divisible by 400 to be a leap year
if (year % 100 == 0) {
if (year % 400 == 0) {
cout << year << " - leap year" << endl;
} else {
cout << year << " - not a leap year" << endl;
}
} else {
// Non-century year divisible by 4 is a leap year
cout << year << " - leap year" << endl;
}
} else {
// Year is not divisible by 4, so not a leap year
cout << year << " - not a leap year" << endl;
}
return 0;
}
Editor is loading...
Leave a Comment