java打星星

来源:百度知道 编辑:UC知道 时间:2024/05/22 18:43:28
怎样打正反金字塔,并且代码要最简化

自己看啦
public class test {
public static void main(String[] args) throws IOException{
for(int i = 1; i <= 10; i++){
for(int t = 1; t <= 10 - i; t++)
System.out.print(" ");
for(int j = 1; j <= i; j++)
System.out.print(" *");
System.out.println();
}
for(int i = 1; i <= 10; i++){
for(int t = 1; t <= i; t++)
System.out.print(" ");
for(int j = 1; j <= 10 - i; j++)
System.out.print(" *");
System.out.println();
}
}
}