public class heart {
public static void main(String[] args) {
trapezoid();
side();
triangle();
}
public static void trapezoid(){
//第一个梯形
for (int i = 0; i<=3 ; i++) { //高度调节
for (int j =9-i; j>=0; j--) { //距离调节
System.out.print(" ");
}
for (int j =0; j<i*2+6 ; j++) {
System.out.print("*");
}
for (int j =2-i; j>=0; j--) {
System.out.print(" ");
}
for (int j =2-i; j>=0; j--) {
System.out.print(" ");
}
for (int j =0; j<i*2+6 ; j++) {
System.out.print("*");
}
System.out.println("");
}
}
public static void triangle(){
for (int i = 0; i <= 11; i++) {
for (int j = 0; j < i+7; j++) { //距离调节
System.out.print(" ");
}
for (int k = 24 - i * 2; k > 1; k--) { //高度调节
System.out.print("*");
}
System.out.println("");
}
}
public static void side(){
for (int i = 0; i <2 ; i++) { //高度
for (int j = 0; j <6 ; j++) {//宽度
System.out.print(" ");
}
for (int j = 0; j <25; j++) { //长度
System.out.print("*");
}
System.out.println("");
}
}
}
控制台输出心型
最新推荐文章于 2024-07-15 22:25:10 发布