Demo entry 6837953

001

   

Submitted by anonymous on Jun 11, 2019 at 09:00
Language: C. Code size: 570 Bytes.

#include<stdio.h>
int main()
{
    printf("以下为2000年到2500年之间的闰年:\n");
	int year,nian,count;
//year是所有年份 nian是闰年 count是计数器
    count=0;
	year=2000;
    while (year<=2500)
	{
		if (year%100==0)
		{
			if(year%400==0)
			{
				nian=1;
                count=count+1;
				printf("%5d年",year);
			}
			else
			{
				nian=0;
			}
		}
		else
		{
			if(year%4==0)
			{
				nian=1;
                count=count+1;
				printf("%5d年",year);
			}
			else
			{
				nian=0;
			}
		}
		year=year+1;
	}
    printf("\n共%d个闰年\n",count);
return 0;
} 

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).