题目1070:今年的第几天?
参考代码:
import java.util.*;
public class Main {
public static void main(String arg[]) {
int[] month1={31,28,31,30,31,30,31,31,30,31,30,31};
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int totaldays=0;
int year = sc.nextInt();
//闰年判断
int flag=0;
if((year%100!=0&&year%4==0) || year%400==0) flag=1;
int month = sc.nextInt();
for(int i=0;i<month-1;i++) totaldays +=month1[i];
int day = sc.nextInt();
totaldays = totaldays+day+flag;
System.out.println(totaldays);;
}
}
}