import java.util.Scanner;
class Demo1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入正三角zz");
int x = sc.nextInt();
Xing(x);
}
public static void Xing(int x){
for (int i = 0;i < x;i++ ) {
for (int j =0;j < x -1 - i;j++ ) {
System.out.print(" ");
}
for (int k = 0;k <= i;k++ ) {
System.out.print("*"+" ");
}
System.out.println(" ");
}
}
}
这段代码就是输入一个数能打印出正三角形,不过我看了半天都没看懂,这个到底怎么读的呢?有没有大神帮忙做个详细点的解释,小白很捉急,谢谢啊! |