C语言实验——某年某月的天数(java转义字符'\')
2017-03-08 11:14
567 查看
C语言实验——某年某月的天数
Time Limit: 1000MS Memory Limit: 65536KBSubmit Statistic
Problem Description
输入年和月,判断该月有几天?
Input
输入年和月,格式为年\月。
Output
输出该月的天数。
Example Input
2009\1
Example Output
31
Hint
注意判断闰年啊
Author
import java.util.*; import java.math.*; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); String line = input.nextLine().trim(); String array[] = line.split("\\\\"); int year = Integer.parseInt(array[0]); int month = Integer.parseInt(array[1]); int day=0; switch(month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: day = 31; break; case 2: if((year%100!=0&&year%4==0)||(year%400==0)) { day = 29; } else day = 28; break; case 4: case 6: case 9: case 11: day = 30; break; } System.out.println(day); } }
相关文章推荐
- C语言实验——某年某月的天数(Java编写)
- JAVA语言实验——某年某月的天数
- C语言实验——某年某月的天数
- C语言实验——某年某月的天数
- C语言实验——某年某月的天数
- C语言实验——某年某月的天数
- Problem G: C语言实验——某年某月的天数
- JAVA_某年某月的天数(split())
- java循环某年某月的所有天数
- c语言 某年某月的天数
- C语言实验——某年某月的天数
- 问题 G: C语言实验题——某年某月的天数(JSU-ZJJ)
- java某年某月的天数
- java 获取某年某月的最大天数
- oj1983: C语言实验——某年某月的天数
- C语言实验——某年某月的天数
- 1160C语言实验——某年某月的天数
- 求用JAVA计算某年某月的天数?(两种方法)
- C语言实验——某年某月的天数
- Java-判断某年某月的天数