打印心形
int count=0;
for (float y = (float) 1.5; y > -1.5; y -= 0.1) {
for (float x = (float) -1.5; x < 1.5; x += 0.05) {
float a = x * x + y * y - 1;
if ((a * a * a - x * x * y * y * y) <= 0.0) {
System.out.print("^");
} else
System.out.print(".");
}
count++;
System.out.println(count);
}
附上心形打印效果,其中条件可自行修改,修改后的效果也附上
修改条件后的效果
全选,查找 9
//99669999996669999996699666699666999966699666699
//99699999999699999999699666699669966996699666699
//99669999999999999996699666699699666699699666699
//99666699999999999966666999966699666699699666699
//99666666999999996666666699666699666699699666699
//99666666669999666666666699666669966996699666699
//99666666666996666666666699666666999966669999996
666666666666666666666666666666666666666666666666666666666666666666666666666996666666666666699666666666666
666666666666666666666666666666666666666699999999996666666666666666666699999999999999999999999999999666666
666666669999999999999999966666666666666666669996666666666666996666666666666996666666666666699666666666666
666666666666666996666666666666666666699999999999999999666666996666666666666666666699666666666666666666666
666666666666666996666666666666666666666666669996666666669966996666666666999999999999999999999996666666666
666666669999999999999999966666666666666669969996996666669966996666666666666666666996666666666996666666666
666666666666666996666666666666666666666699669996699666669966996666666666666666669966666666666996669966666
666666666666666996666666666666666666666996669996669966666666996666666666669966699666666666666996666666666
666666669999999999999999966666666666669966669996666666666996996666666666666666996666666666996996666666666
666666666666666666666666666666666666666666669996666666666669996666666666666699666666666666699966666666666