#include <stdio.h>
main(void)
{
int y , m , d ;
scanf("%d%d" , & y , & m) ;
switch(m) {
case 1: d = 31 ; break ;
case 2: d = (! (y % 4) && y % 100 || ! (y % 400)) ? 29:28 ; break ;
case 3: d = 31 ; break ;
case 4: d = 30 ; break ;
case 5: d = 31 ; break ;
case 6: d = 30 ; break ;
case 7: d = 31 ; break ;
case 8: d = 31 ; break ;
case 9: d = 30 ; break ;
case 10: d = 31 ; break ;
case 11: d = 30 ; break ;
case 12: d = 31 ; break ;
default: d = 0 ; break ;
}
if(d) printf("%d\n" , d) ;
else printf("wrong data .\n") ;
}
编译、运行实况D:\0002.Exercise\C>g++ -o x x.c
D:\0002.Exercise\C>x
2000 2
29
D:\0002.Exercise\C>x
2004 2
29
D:\0002.Exercise\C>x
2001 2
28
D:\0002.Exercise\C>
|