java某年某月的天数
2017-04-15 16:32
288 查看
Problem Description
输入年和月,判断该月有几天?Input
输入年和月,格式为年\月。Output
输出该月的天数。Example Input
2009\1
Example Output
31
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); String s=in.nextLine(); String a[]=s.split("\\\\"); int year=Integer.parseInt(a[0]); int month=Integer.parseInt(a[1]); int flag=1; if(year%4==0&&year%100!=0||year%400==0) {flag=0;} if(month==1||month==3||month==5||month==7||month==8||month==10||month==12) {System.out.println("31");} else if(month==4||month==6||month==9||month==11) {System.out.println("30");} else if(month==2) { if(flag==1) {System.out.println("28");} else {System.out.println("29");} } } }
相关文章推荐
- C语言实验——某年某月的天数(java转义字符'\')
- C语言实验——某年某月的天数(Java编写)
- java 获取某年某月的最大天数
- 求用JAVA计算某年某月的天数?(两种方法)
- JAVA_某年某月的天数(split())
- Java-判断某年某月的天数
- JAVA语言实验——某年某月的天数
- java循环某年某月的所有天数
- js获取某年某月天数
- PHP 如何得到某年某月的天数
- 求某年某月的天数
- SQL 查找某年某月的天数
- php获取某年某月的天数
- C#获取某年某月的天数
- 如何获取某年某月的最大天数
- Java获取某年某月的最后一天
- 黑马程序员:获取任意某年某月天数
- VS.NET获取某年某月的天数
- VB6 获取某年某月天数函数
- 获取某年某月的天数(非常简单)