以后最好把自己先写一下,然后贴出来大家帮你乱陪册完善,以哗宏下程序调试乱含通过:
main(){
int y,m,d;
printf("year,month=");scanf("%d%d",&y,&m);
switch(m){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:d=31;break;
case 4:
case 6:
case 9:
case 11:d=30;break;
case 2:if (y%4==0 && y%100!=0 || y%400==0) d=29; else d=28;
}
printf("days=%d\n",d);
}
VB版:
dim y as integer,m as integer,flag as boolean
y=inputbox("请输入年份铅颤")
m=inputbox("请输入月份槐答败")
if(y mod 4=0 and y mod 100<举碰>0) or y mod 400=0 then flag=ture '判断是否闰年
select case m
case 1,3,5,7,8,10,12:text1="31"
case 4,6,9,11:text1="30"
case 2:if flag then
text1="28"
else
text1="29"
end select
C语言版:
main()
{int y,m,flag=0;
scanf("%d%d",&y,&m);
if((y%4==0 && y%100!=0)||y%400==0) flag=1
switch(m)
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:printf("d%",31);break;
case 2:flag?printf("d%",28):printf("d%",29);break;
default: printf("d%",30);
}