代码语言:javascript复制
package *;
/**
* @program: data-structure
* @description: 心形
* @author: ChenWenLong
* @create: 2019-09-10 16:06
**/
public class Heart {
public static void main(String[] args) {
createHeart();
}
/**
* 功能描述:
* 〈创建心形〉
*
* @params : []
* @return : void
* @author : cwl
* @date : 2019/9/10 16:07
*/
public static void createHeart(){
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(" ");
}
System.out.println();
}
}
}