游客 Signup | Login
中文 | En

1230 - C语言9.4

定义一个宏,对于输入的一个年份,判断其是否是闰年。

要求使宏名为LEAP_YEAR,形参为y,即定义宏的形式为:

define LEAP_YEAR(y) ......

Input

一个正整数year。

Output

如果输入的年份year是闰年,则首先输出year的值,然后输出” is a leap year.”;否则若输入的年份不是闰年,则同样首先输出year的值,然后输出” is not a leap year.”。

请注意行尾输出换行。

Examples

Input

2013

Output

2013 is not a leap year.

Solution C

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

Solution C++

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

Time Limit 1 second
Memory Limit 32 MB
Discuss Stats
上一题 下一题