import java.util.Random;
public class Main {
static final Random random = new Random();
static final char[] dots = new char[]{'*', '#', '.', '-', '\n'};//马里奥场景中包含的字符
static final int rowLimit = 62;//场景中一行最多有62个字符
public static void main(String[] args) {
//随机输出字符
final int colLen = 22;//场景有22行
for (int count = 0; count < colLen; count++) {
randomInputRow();
}
}
//随机输出一行字符,换行或到上限结束
static void randomInputRow() {
for (int count = 0; count < rowLimit; count++) {
char rand = dots[random.nextInt(dots.length)];
System.out.print(rand);
if (rand == '\n') break;
}
}
}
这是最方便的解法吗