要求:产生n行,每行由m个随机的大写字母组成的字符串.随机种子为100
代码填空:
public class Main {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
Random r1 = new Random();
r1.setSeed(100);
int n = in.nextInt();
int m = in.nextInt();
int x;
for (int i = 1; i <= n; i++) {
String s = "";
//代码填空第1行,m作为循环变量的循环结构
//代码填空第2行,给x赋值,x为65到90之间的一个随机整数
s = s + (char) x;
}
System.out.println(s);
}
}
}
输入n
n行m列的字符串
10
5
ZUAKV
QEKDB
YPGRU
HIARJ
ZQTUH
HMGMQ
MDIRC
YZEWX
VEFTV
SZFIA
import java.util.Random;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Random r1 = new Random();
r1.setSeed(100);
int n = in.nextInt();
int m = in.nextInt();
int x;
for (int i = 1; i <= n; i++) {
String s = "";
//代码填空第1行,m作为循环变量的循环结构
for (int j = 0; j < m; j++) {
//代码填空第2行,给x赋值,x为65到90之间的一个随机整数
x = 65+r1.nextInt(26);
s = s + (char) x;
}
System.out.println(s);
}
}
}