输入样例:
10 a
输出样例:
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
java
行是列的一半 偶数除2 奇数除2+1
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sca = new Scanner(System.in);
String[] s = sca.nextLine().split(" ");
int rows = 0;
//判断共有多少行
if (Integer.parseInt(s[0]) % 2 == 0) {
rows = Integer.parseInt(s[0]) / 2;
} else rows = Integer.parseInt(s[0]) / 2 + 1;
//输出
for (int i = 0; i < rows; i++) {
for (int j = 0; j < Integer.parseInt(s[0]); j++) {
System.out.print(s[1]);
}
System.out.println();
}
}
}