当前位置: 代码迷 >> 综合 >> C语言实验——某年某月的天数 oj
  详细解决方案

C语言实验——某年某月的天数 oj

热度:46   发布时间:2024-01-14 23:15:46.0

C语言实验——某年某月的天数

Time Limit: 1000MS  Memory Limit: 65536KB
Submit  Statistic
Problem Description
输入年和月,判断该月有几天?
Input
输入年和月,格式为年\月。
Output
输出该月的天数。
Example Input
2009\1
Example Output
31
Hint
注意判断闰年啊
Author
#include <stdio.h>int main()
{int year,month;scanf("%d\\%d",&year,&month);if(month==1)printf("31\n");else if(month==3)printf("31\n");else if(month==4)printf("30\n");else if(month==5)printf("31\n");else  if(month==6)printf("30\n");else if(month==7)printf("31\n");else if(month==8)printf("31\n");else if(month==9)printf("30\n");else if(month==10)printf("31\n");else if(month==11)printf("30\n");else if(month==12)printf("31\n");else if(month==2){if((year%4==0&&year%100!=0)||(year%400==0))printf("29\n");elseprintf("28\n");}return 0;
}



  相关解决方案