2009/10/25

[ C/C++ ] Leap Year Check

閏年定義(leap year or intercalary year) : 四年一閏,百年不閏,四百年閏,四千年閏

英文字典 leap year ?
A leap year is a year which has 366 days. The extra day is the 29th February. There is a leap year every four years.

// leapyear.cpp
//
// This program to determine leap year.
//
// Console-based
// Retruns real as well as comples roots.
// Author Jim.lin 2009

#include <iostream>

using namespace std;

int main()
{
    int year;
        cin >> year;
    if(( year%4==0 && year%100!=0 ) || year%400==0 )
        cout << "Leap Year ";
    else
        cout << "Not Leap Year ";
    return 0;
}
Ref. By Google.

0 意見: