[java]代码库
Scanner scan = new Scanner(System. in);
System. out .print("请输入年:" );
int year = scan.nextInt();
System. out .print("请输入月:" );
int month = scan.nextInt();
System. out .print("请输入日:" );
int day = scan.nextInt();
int sum = 0; //计数器
switch(month){
case 12:
sum += 30;
case 11:
sum += 31;
case 10:
sum += 30;
case 9:
sum += 31;
case 8:
sum += 31;
case 7:
sum += 30;
case 6:
sum += 31;
case 5:
sum += 30;
case 4:
sum += 31;
case 3:
if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0){
sum += 29;
} else{
sum += 28;
}
case 2:
sum += 31;
case 1:
sum += day;
}
System. out .println("当年的第 " + sum + " 天" );
by: 发表于:2017-06-27 15:25:02 顶(0) | 踩(0) 回复
??
回复评论