题解 | #反斜线形图案#
反斜线形图案
http://www.nowcoder.com/practice/7b066963c4eb4d188becd18c37dfe22d
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while(scan.hasNextInt()) {
int n = scan.nextInt();
int[][] arr = new int[n][n];
for(int i = 0; i < arr.length; i++) {
for(int j = 0; j < arr[i].length; j++) {
if(i == j) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
}
}
Java基础练习题 文章被收录于专栏
都是一些基础的语法题目,每天可以刷几道。