游客 Signup | Login
中文 | En

3261 - 例题4-8 判断闰年

输入一个年份,判断该年份是否为闰年。如果是输出该年份是一个闰年,否则输出该年份不是闰年的信息。

Input

年份

Output

输出结果的格式如下所示:

输入的年份 is a leap year!

输入的年份 is not a leap year!

注意末尾输出换行。

Examples

Input

1900

Output

1900 is not a leap year!

Solution C

#include<stdio.h>
int main()
{
	int year;
	scanf("%d",&year);
	if((year%4==0 && year%100!=0)||(year%400==0))
		printf("%d is a leap year!\n",year);
	else printf("%d is not a leap year!\n",year);
	getchar();
	getchar();
	return 0;
}

Solution C++

#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    int a;
    cin>>a;
    //如果a不能被100整除且a能被4整除,a就是闰年
    //如果a能被400整除,a就是闰年。
    if( (a%100 != 0  && a%4 == 0) || (a%400 == 0) )
    {
        cout<<a<<" is a leap year!"<<endl;
    }
    else
    {
        cout<<a<<" is not a leap year!"<<endl;
    }    
    return 0;
}
Time Limit 1 second
Memory Limit 12 MB
Discuss Stats
上一题 下一题