在树莓派上用yolov7训练图像识别模型
时间: 2023-09-08 19:09:32 浏览: 100
使用if语句:
```java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("请输入年月(格式为yyyy-MM):");
String input = scanner.nextLine();
int year = Integer.parseInt(input.substring(0, 4));
int month = Integer.parseInt(input.substring(5));
int days = 0;
if (month == 2) {
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
days = 29;
} else {
days = 28;
}
} else if (month == 4 || month == 6 || month == 9 || month == 11) {
days = 30;
} else {
days = 31;
}
System.out.println(year + "年" + month + "月有" + days + "天");
}
}
```
使用switch语句:
```java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("请输入年月(格式为yyyy-MM):");
String input = scanner.nextLine();
int year = Integer.parseInt(input.substring(0, 4));
int month = Integer.parseInt(input.substring(5));
int days = 0;
switch (month) {
case 2:
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
days = 29;
} else {
days = 28;
}
break;
case 4:
case 6:
case 9:
case 11:
days = 30;
break;
default:
days = 31;
break;
}
System.out.println(year + "年" + month + "月有" + days + "天");
}
}
```
阅读全文