import java.util.Scanner;
public class Demo{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("请输入年份");
int year = input.nextInt();
System.out.print("请输入月份");
int month = input.nextInt();
System.out.print("请输入几号");
int day = input.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: count += 28;
case 2: count += 31;
case 1: count += day;
}
System.out.print("今天是一年中的第"+count+"天");
}
}
妙用switch 计算几天是 一年的第几天
最新推荐文章于 2023-05-10 00:00:17 发布