【C语言】每日一代码:获得月份天数

#define _CRT_SECURE_NO_WARNINGS
#include

int main()
{
	int year = 0;
	int month = 0;
	while (scanf("%d %d", &year, &month) != EOF)
	{
		switch (month)
		{
		case 2:
			if (year % 400 == 0 || year % 4 == 0 && year % 100 != 0)
			{
				printf("29天\n");
			}
			else
			{
				printf("28天\n");
			}
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			printf("30天\n");
			break;
		default:
			printf("31天\n");
			break;
		}
	}
	return 0;
}

你可能感兴趣的:(c语言,算法,开发语言)