You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
/*example2-3.c*/
|
|
|
|
|
#include<stdio.h>
|
|
|
|
|
main()
|
|
|
|
|
{ int year,month,day;
|
|
|
|
|
|
|
|
|
|
printf("Enter year & month:");
|
|
|
|
|
scanf("%d%d",&year,&month); /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD><DDBA>·<EFBFBD>*/
|
|
|
|
|
if (month==2) /*<2A>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>·<EFBFBD>*/
|
|
|
|
|
if ((year%4==0&&year%100!=0)||(year%400==0)) /*<2A>Ƕ<EFBFBD><C7B6>·ݣ<C2B7><DDA3>ж<EFBFBD><D0B6>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>*/
|
|
|
|
|
day=29;
|
|
|
|
|
else day=28;
|
|
|
|
|
else /*<2A><><EFBFBD>Ƕ<EFBFBD><C7B6>·ݣ<C2B7><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϸ<D0B6><CFB8>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
switch (month)
|
|
|
|
|
{
|
|
|
|
|
case 1: case 3:
|
|
|
|
|
case 5: case 7:
|
|
|
|
|
case 8: case 10:
|
|
|
|
|
case 12: day=31; break; /*<2A><><EFBFBD><EFBFBD>case<73><65><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
case 4: case 6:
|
|
|
|
|
case 9: case 11: day=30; break;
|
|
|
|
|
}
|
|
|
|
|
printf("year=%d month=%d day=%d\n",year,month,day);
|
|
|
|
|
}
|