⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 润年11.cpp

📁 输入年份和月份
💻 CPP
字号:
//判断润年
#include<stdio.h>
void main()
{
	int year,month,a,b;
	printf("Enter a year:\n");
	scanf("%d",&year);
	printf("Enter a month:\n");
	scanf("%d",&month);
	if(year<0||month>12||month<1)
	
	{
		printf("You enter the val is not true\nPlease enter another val\n");

	}
	else
	{
	a=year%4;
	b=year%400;
 
 
	switch(a)
	{
	case 1:
	case 2:
	case 3:
		printf("%d is not a leap year",year);
		break;

	case 0:
		switch(b)
			{
		case 100:
		case 200:
		case 300:
			printf("%d is not a leap year",year);
			break;
	
		case 0:
			printf("%d is a leap year ",year);
			break;
	
	}
		if(year%4==0&&year%100!=0)
		printf("%d is a leap year ",year);
		break;
	}
			switch(month)
		{
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
			case 12:
				printf("\nThis year is %d\nThe month is %d\nThere are 31 days\n",year,month);
				break;
			case 4:
			case 6:
			case 9:
			case 11:
				printf("\n This year is %d\nThe month is %d\nThere are 30 days\n",year,month);
				break;

			case 2:
			if((year%4==0&&year%100!=0)||(year%400==0))
			{
				printf("\nThis year is %d\nThe month is 2\nThere are 29 days\n",year);

			}
			else
			{
				printf("\nThis year is %d\nThe month is 2\nThere are 28 days\n",year);
			
			}
			break;
		
	
 
 }
}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -