这个该怎么写,完全没有头绪,只能写出来一点点,没办法运行啊,求解惑。
答:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// 读取一维数组的[大](https://www.meipian.cn/c/501446981)[小](https://my.oschina.net/u/4474619)
System.out.print("[请](https://www.zhihu.com/column/c_1464910203380936704)[输](https://space.bilibili.com/1369953785/article)入一维值:");
int n = sc.nextInt();
// 定义二维数组并录入数据
int[][] arr = new int[n][];
for (int i = 0; i < n; i++) {
int m = (int) (Math.random() * 10); // 随机生成二维数组的长度
arr[i] = new int[m];
for (int j = 0; j < m; j++) {
arr[i][j] = (int) (Math.random() * 100); // 生成 0~99 之间的随机整数
}
}
// 按数组格式输出
for (int i = 0; i < n; i++) {
for (int j = 0; j < arr[i].length; j++) {
System.out.print(arr[i][j] + " ");
}
System.out.println();
}
}
}