kikit
6/20/2016 - 1:52 PM

Leap Year checking

Leap Year checking

/*
http://ideone.com/flMEIl
*/
#include <iostream>
using namespace std;

bool leapYear(int n){
	if(n % 400 == 0)
		return true;
	else if(n % 100 == 0)
		return false;
	else if(n % 4 == 0)
		return true;
	else
		return false;
}
/*  ------------------------------------------------
isleap(int y)
{
    return y%4==0 && (y%100 != 0 || y%400 == 0);
}
------------------------------------------------------ */
int main() {
	// your code goes here
	int n, year;
	cin >> n;
	while(n--){
		cin >> year;
		cout << year << " : ";
		if(leapYear(year))
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}