展开全部
按照你原来的思路,你可能更好理解点public static void main(String[] args) {
for (int i = 1; i <= 7; i++) {
for (int j = 7; j > i; j--) {
System.out.print(" ");
}
for (int m = 1; m <= i; m++) {
int num1 = m;
int num2 = 1;
if (num1 == 1) {
num2 = 1;
} else {
int num3 = num1 - 1;
while (num3 > 0) {
num2 = num2 * 2;
num3--;
}
}
System.out.print(num2 + " ");
}
for (int m = 1; m
int num1 = m;
int num2 = 1;
int temp = 1;
while(++temp!=i){//计算开始递减e69da5e887aa3231313335323631343130323136353331333337383338的初始值
num2 = 2 * num2;
}
int num3 = num1 - 1;
while (num3 > 0) {
num2 = num2 / 2;
num3--;
}
System.out.print(num2 + " ");
}
System.out.println();
}
}
运行结果: