年月.cpp

来自「解压后 每个.cpp都有中文名很清楚。我是初学者」· C++ 代码 · 共 47 行

CPP
47
字号
#include<stdio.h>
void main()
{
    int year,month;
	printf("\nenter the year: ");
	scanf("%d",&year);
  rewrite:
	printf("\enter the month: ");
	scanf("%d",&month);
	if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
		printf("the year u entered is a leap year!\n");
	else 
		printf("the year is not a leap year\n"); 

	if (month>=1 && month<=3)
		printf("the month is the first one\n");
	else if (month>=4 && month<=6)
		printf("the second ji du\n");
	else if (month>=7 && month<=9)
		printf("the third one\n");
	else if (month>=10 && month<=12)
		printf("the fourth one\n");
	else 
	   {printf("there is no month like u entered!\n");
        goto rewrite; 
	}
	
	if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
	{
		if (month==2)
	    printf("there are 29 days in the second month.\n");
     else if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12 && month!=2)
	    printf("there are 31 days int this months.\n");
     else if (month==4 || month==6 || month==9 || month==11 && month!=2)
        printf("there are 30 days in this months.\n");
	}
	else if (year % 4 != 0 || year % 400 != 0)
	{
		if (month==2)
	    printf("there are 28 days in the second month.\n");
     else if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12 && month!=2)
	    printf("there are 31 days int this months.\n");
     else if (month==4 || month==6 || month==9 || month==11 && month!=2)
        printf("there are 30 days in this months.\n"); 
	}

}

⌨️ 快捷键说明

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