public class Main {
public static void main(String[] args) {
int rows = 10;
for (int i = 0; i < rows; i++) { int number = 1; // 打印空格字符串 System.out.format("%" + (rows - i) * 2 + "s", ""); for (int j = 0; j <= i; j++) { System.out.format("%4d", number); number = number * (i - j) / (j + 1); } System.out.println(); } }
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)