java编写程序打印输出以下图形。 * ** *** **** ***** **** *** ** *

如题所述

public class Diamond {

public static void main(String[] args) {

for(int i = 1; i <= 5; i++){
for(int j = 1; j <= i; j++){
System.out.print("*");
}

System.out.println();
}

for(int i = 4; i >= 1; i--){
for(int j = 1; j <= i;j++){
System.out.print("*");
}

System.out.println();
}

}
}
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答