Problem DescriptionEnter the year and month to determine how many days the month is.
InputEnter the year and month, in the form of year \ Month.
OutputThe number of days that the month is exported.
Example Input
2009\1
Example Output
31
#include <stdio.h>
int main ()
{
int y,m,d;
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 ("%d\n", D);
return 0;
}
Or
#include <stdio.h>
int main ()
{
int y,m,d;
scanf ("%d\\%d", &y,&m);
Switch (m)
{
Case 1:printf ('%d\n '); break;
Case 3:printf ("%d\n");
Case 5:printf ("%d\n";);
Case 7:printf ("%d\n";);
Case 8:printf ("%d\n";);
Case 10:printf ("%d\n";);
Case 12:printf ("%d\n";);
Case 4:printf ("%d\n");
Case 6:printf ("%d\n");
Case 9:printf ("%d\n");
Case 11:printf ("%d\n");
Case 2:
if ((y%4==0&&y%100!=0) | | (y%400==0)) printf ("%d\n", 29);
Else printf ("%d\n", 28);
break;
}
return 0;
}