双重循环输出

package day04;
import java.util.*;
public class Demo12 {
static Scanner sr =new Scanner(System.in);
public static void main(String[] args) {
System.out.println("你像要几行数字?");
int num =sr.nextInt();
//行数
for(int i=1;i<=num;i++){
//空格
for(int j = 1; j <= num-i; j++) {
System.out.print(" ");
}
//列数
for(int j = 1; j <=2*i-1; j++) {
System.out.print(i);
}
System.out.println();
}
}
}


猜你喜欢

转载自www.cnblogs.com/zhangbupang/p/11121403.html