“21天好习惯”第一期-21

这是计算有多少个闰年的题目。

从键盘输入你的出生年和今年的年份,编程判断并输出从你的出生年到今年之间中有多少个闰年。

程序的运行结果示例1: 

Input your birth year:2000↙

Input this year:2020↙

2000

2004

2008

2012

2016

2020

count=6

代码如下:

#include<stdio.h>
int main()
{
int a,b,i,j=0;
printf("Input your birth year:");
scanf("%d",&a);
printf("Input this year:");
scanf("%d",&b);
for (i=a;i<=b;i++)
{
if ((i%4==0&&i%100!=0)||i%400==0)
{j++;
printf("%d\n",i);}
}
printf("count=%d\n",j);
return 0;
}

上一篇:* Please tell me who you are. git 使用发现问题


下一篇:解决 Timeout expired. The timeout period elapsed prior to completion of the operation or the server is