代码很简单(没有任何高级操作),只有简单的循环和选择
import java.util.Scanner;
public class Cinema {
static int countTen;
static int countEight;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the number of rows:");
int rows = scanner.nextInt();
System.out.println("Enter the number of seats in each row:");
int seats = scanner.nextInt();
if ((seats > 9) || (rows > 9)){
return;
}
String[][] allSeat = new String[rows][seats];
//二维数组初始化
for (int r = 0; r < rows; r++){
for (int s = 0; s < seats; s++){
allSeat[r][s] = " S";
}
}
System.out.println();
boolean check = true;
countTen = 0;
countEight = 0;
while (check){
check = menu(rows,seats,countTen,countEight,
allSeat, true);
}