System.out.println("请输入你的要查询的年份");
Scanner scanner = new Scanner(System.in);
int year = scanner.nextInt();
int shengXiao = year % 12;
switch (shengXiao){
case 0:
System.out.println("猴年");
break;
case 1:
System.out.println("鸡年");
break;
case 2:
System.out.println("狗年");
break;
case 3:
System.out.println("猪年");
break;
case 4:
System.out.println("鼠年");
break;
case 5:
System.out.println("牛年");
break;
case 6:
System.out.println("虎年");
break;
case 7:
System.out.println("兔年");
break;
case 8:
System.out.println("龙年");
break;
case 9:
System.out.println("蛇年");
break;
case 10:
System.out.println("马年");
break;
case 11:
System.out.println("羊年");
break;
case 12:
System.out.println("猴年");
break;
default:
System.out.println("输入有错");
}
编写一个程序,为一个给定的年份找出其对应的中国生肖。中国的生肖基于12年一个周期, 每年用一个动物代表:rat、ox、tiger、rabbit、dragon、snake、horse、sheep、mon
最新推荐文章于 2024-01-04 14:16:41 发布