【C语言】求1000-2000年的闰年,并统计个数

来源:互联网 发布:cctv软件下载 编辑:程序博客网 时间:2024/06/10 19:33

    总结的求闰年的口诀:

         四年一闰,百年不闰,四百年再闰。




#include<stdio.h>#include<stdlib.h>void LeapYear(){    int year = 1000;    int count = 0;    for (; year < 2000; year++)    {        if (year % 4 == 0            && year % 100 != 0            || year % 400 == 0)        {            printf("%d    ", year);            count++;        }    }    printf("\n");    printf("count = %d", count);}int main(){    LeapYear();    system("pause");    return 0;}
0 0
原创粉丝点击