#include<stdio.h> int main() { int a,b,c; scanf("%d-%d-%d",&a,&b,&c); if(a < 0 || a > 3000 || c > 31 || c < 0 || b> 12 || b < 0 ) {printf("NO\n");}//判断范围 else{if (b==1||b==3||b==5||b==7||b==8||b==8||b==10||b==12) { if(c>0&&c<=31){printf("YES");}else {printf("NO");} } else{if(b!=2){if(c>0&&c<=30){printf("YES");}else{printf("NO");}} else{if((a % 100 !=0&&a % 4 == 0)||a % 400 == 0){if(c>0&&c<=29){printf("YES");}else{printf("NO");}} else{if(c>0&&c<=28){printf("YES");}else{printf("NO");}} } } } return 0; }
转载于:https://www.cnblogs.com/p201821430005/p/10510946.html