题解 | #X形图案#
X形图案
http://www.nowcoder.com/practice/83d6afe3018e44539c51265165806ee4
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNextInt()) {
int n = scanner.nextInt();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (i == j || i + j == n - 1) {
System.out.print("*");
}else {
System.out.print(" ");
}
}
System.out.print("\n");
}
}
}
}
编程初学者入门训练 文章被收录于专栏
针对编程初学者入门训练130题的代码详解专栏,内附注释方便理解,牛客130题的代码均用C语言实现,方便初学者学习。