我的写法:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int year=sc.nextInt(); int month=sc.nextInt(); if((year%4==0&&year%100!=0)||year%400==0) { if(month==1||month==3||month==5||month==7||month==8||month==10||month==12) System.out.println(31); else if(month==2) System.out.println(29); else System.out.println(30); } else { if(month==1||month==3||month==5||month==7||month==8||month==10||month==12) System.out.println(31); else if(month==2) System.out.println(28); else System.out.println(30); } } }我是新手,代码还很幼稚,如果有更好的改进,请告诉我。
不知道有没有办法可以把月份的或运算进行简化?
