java写的爱心

运行效果

源代码: 

package com.softeem.wolf.test;

/**
 * Created by 苍狼
 * Time on 2021-11-23
 */
public class Test01 {
    public static void main(String[] args) {
        for (float y = 1.5f; y>-1.5f; y-=0.1f){
            for (float x = -1.5f; x<1.5f; x+=0.05f){
                float a = x*x+y*y-1;
                if ((a*a*a-x*x*y*y*y)<0.0f){
                    System.out.print("♥");
                    try {
                        Thread.sleep(5);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                } else {
                    System.out.print(" ");
                }
            }
            System.out.print("\n");
        }
    }
}

需要源代码的可以自取.

猜你喜欢

转载自blog.csdn.net/m0_50370837/article/details/121513174