题解 | #求int型正整数在内存中存储时1的个数#
计算日期到天数转换
http://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int year = in.nextInt();
int month = in.nextInt();
int day = in.nextInt();
int count = 0;
switch(month){
case 12:
count += 30;
case 11:
count += 31;
case 10:
count += 30;
case 9:
count += 31;
case 8:
count += 31;
case 7:
count += 30;
case 6:
count += 31;
case 5:
count += 30;
case 4:
count += 31;
case 3:
if((year%4 == 0 &&year %100 != 0)||year % 400 == 0){
count+=29;
}
else
count += 28;
case 2:
count += 31;
case 1:
count += day;
}
System.out.println(count);
}
}