java_输入年份和天数,输出月份和日期

package ccf;
import java.io.*;
import java.util.*;;
public class bowen003 {
	public static void main(String[] args) {
          // TODO Auto-generated method stub
		//1  get year and day --input  test passed
		Scanner input = new Scanner(System.in);
		int year = input.nextInt();
	         //getday
		int day = input.nextInt();
	   /*System.out.println(year);
	   System.out.println(day);*/
	
         int month=1;
         int monthday[] = {31,28,31,30,31,30,31,31,30,31,30,31};
		
		if(year%400==0||(year%4==0)&&(year%100!=0)) {
			monthday[1] = 29;
		}
		for(int i=0;day-monthday[i]>0;++i) {
			day-= monthday[i];
			 ++month;
			}
		System.out.println(month);
		System.out.println(day);
		}
}

你可能感兴趣的:(Java)