//输出1000年,(包括1000年)到1999年之间所有的闰年,要求每3个一行,分析输出
//1.enter the nember
//2.pickout the '闰年'
//3.putout the reasult
#include <stdio.h>
int main()
{int x=1000,y=1999;
printf("所有的闰年");
for(x=1000;x<=y;x=x+12)
{if(((y-x)>=12)&&(x%4==0))//=为赋值,==为等号
printf("%d,%d,%d\n",x,x+4,x+8);
else if (((y-x)>=8)&&(x%4==0))
printf("%d,%d\n",x,x+4);
else if (((y-x)>=4)&&(x%4==0))
printf("%d\n",x);
else if (x%4==0)
printf("%d\n",x);
}
return 0;
}
//输入年份和月份,输出这一年的该月的天数
//输入scanf,判断(闰年or平年)if,else。输出printf
#include<stdio.h>
int main()
{int year,month,days;//整型变量
printf("请输入年份和月份");
scanf("%d%d",&year,&month);
{switch(month)
{
case 1:case 3:case 5:case 7:case 8:case 10:case 12:
days=31;
break;
case 2:
{if(year%4==0)
days=28;
else
days=29;
}
break;
default:
days=30;
break;
}
}
printf("该月的天数为%d",days);
return 0;
}