zoukankan      html  css  js  c++  java
  • 算法之浪漫:打印爱心

    public class printHeart {
    
        public static void main(String[] args) {
    
            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) {
                        if (Math.abs(x + 0.100000712) <= 1e-6 && Math.abs(y - 0.6999998) <= 1e-6) {
                            System.out.print("J");
                            continue;
                        }
                        if (Math.abs(x + 0.050000306) <= 1e-6 && Math.abs(y - 0.6999998) <= 1e-6) {
                            System.out.print("a");
                            continue;
                        }
                        if (Math.abs(x + -3.0621885E-7) <= 1e-6 && Math.abs(y - 0.6999998) <= 1e-6) {
                            System.out.print("z");
                            continue;
                        }
                        if (Math.abs(x - 0.049999695) <= 1e-6 && Math.abs(y - 0.6999998) <= 1e-6) {
                            System.out.print("z");
                            continue;
                        }
                        if (Math.abs(x - 0.100000001) <= 1e-6 && Math.abs(y - 0.6999998) <= 1e-6) {
                            System.out.print(" ");
                            continue;
                        }
    
                        System.out.print("*");
    
                    } else
                        System.out.print(" ");
                }
    
                for (float x = (float) 1.5; x < 4.5; x += 0.05) {
                    float a = (x - 3) * (x - 3) + y * y - 1;
                    boolean flag = false;
                    if ((a * a * a - (x - 3) * (x - 3) * y * y * y) <= 0.0) {
                        if (Math.abs(x - 3 + 0.100000712) <= 1e-6 && Math.abs(y - 0.6999998) <= 1e-6) {
                            System.out.print("D");
                            flag = true;
                            continue;
                        }
                        if ((Math.abs(x - 2.9499986)) <= 1e-6 && Math.abs(y - 0.6999998) <= 1e-6) {
                            System.out.print("e");
                            continue;
                        }
                        if (Math.abs(x - 2.9999986) <= 1e-6 && Math.abs(y - 0.6999998) <= 1e-6) {
                            System.out.print("r");
                            continue;
                        }
                        if (Math.abs(x - 3.0499985) <= 1e-6 && Math.abs(y - 0.6999998) <= 1e-6) {
                            System.out.print("e");
                            continue;
                        }
                        if (Math.abs(x - 3.0999985) <= 1e-6 && Math.abs(y - 0.6999998) <= 1e-6) {
                            System.out.print("k");
                            continue;
                        }
    
                        System.out.print("*");
    
                    } else
                        System.out.print(" ");
                }
    
                System.out.print("
    ");
            }
        }
    }
    

      

  • 相关阅读:
    Spring基础问答--来自http://my.oschina.net/u/2260184/blog/540576博客
    一些java异常集
    java汉字乱码解决办法
    oracle数据库-表空间基础语法及举例
    大师传承-java代码编写的30条建议
    oracle的表分区的定义与操作
    数据库备份
    PL/SQL语言编程中异常分类及其处理
    PL/SQL编程基本语法学习
    国药准字和药品本位码
  • 原文地址:https://www.cnblogs.com/qianjinyan/p/11378526.html
Copyright © 2011-2022 走看看