如何使用JAVA一层for循环打印出倒立三角形

如题所述

第1个回答  2016-10-17
必须用到两层循环 因为打印出来的是一个面 而不是一行
第2个回答  2016-10-17
public class Demo {
static int temp =0;
public static void main(String[] args) {
Demo d =new Demo();
d.printView();

}

public void printView(){
if(temp<=5){
for (int i = 0; i < 5-temp; i++) {
System.out.print("*");
}
System.out.println();
temp++;
printView();
}
}
}本回答被提问者采纳