java爱心程序,情人节 Java可以做什么

1,情人节 Java可以做什么程序员表白代码你可以用Java做一个爱心送给心爱的人,可以try , 可以catch,可以throw可以用new一个对象
2,如何用java做出点击窗口就能跳出爱心的程序在窗口上弄一个爱心,用画笔的方法把它绘制在上面,让其按照你自己设计的方式(控制坐标的方法)移动 , 最主要的是使用多线程让它不停刷新你好!弄一个爱心的flash,然后窗口的onclick方法实现希望对你有所帮助,望采纳 。
3,如何用java中的for输出心形public class Teststatic float count(float x, float y)return (float) (Math.pow((x * x + y * y - 1), 3) - x * x * y * y * y); } public static void printEmpty()int height = 50, width = 100;int heart[][] = new int[height][width];float hx = 0.0f, hy = 0.0f;for (int y = height / 2; y > -height / 2; y--)for (int x = -width / 2; x < width / 2; x++)hx = (float) x / (float) (width / 2.8f);hy = (float) (y) / (float) (height / 2.8f);if (count(hx, hy) <= 0.0f)heart[height / 2 - y][x + width / 2] = 1;}}}for (int y = 1; y < height - 1; y++)for (int x = 1; x < width - 1; x++)if (heart[y][x] == 1&& !(heart[y][x - 2] == 1 && heart[y][x + 2] == 1&& heart[y - 1][x] == 1 && heart[y + 1][x] == 1))System.out.print("*");} elseSystem.out.print(" ");}}System.out.println();}System.out.println(); } public static void main(String[] args)printEmpty(); }}【java爱心程序,情人节 Java可以做什么】
4 , 怎么用java的GUI去打印一个爱心嵌套一个面板单独存放固定位置的组件,不要设置布局管理器,自己设置好位置import java.util.scanner;public class test static void draw(int n)int i,j; for (i=1-(n>>1);i<=n;i++)if (i>0)for (j=0;jfor (j=1;j<=2*(n-i)+1;j++) if (j==1||j==2*(n-i)+1) system.out.print(" *"); else system.out.print(" "); system.out.println("\n"); } else if (i==0) { system.out.print(" *"); for (j=1;j system.out.print(" *"); for (j=1;j system.out.print(" *\n"); } else { for (j=i;j<0;j++) system.out.print(" "); for (j=1;j<=n+2*i+1;j++) if (i==1-(n>>1)) system.out.print(" *"); else if (j==1||j==n+2*i+1) system.out.print(" *"); else system.out.print(" "); for (j=1;j<=-1-2*i;j++) system.out.print(" "); for (j=1;j<=n+2*i+1;j++) if (i==1-(n>>1)) system.out.print(" *"); else if (j==1||j==n+2*i+1) system.out.print(" *"); else system.out.print(" "); system.out.print("\n"); } } public static void main(string[] args) { system.out.println("please input the size (n>=4):"); scanner sc = new scanner(system.in); int n = sc.nextint(); draw(n); } }先说明这个不是我写的 是看了有人用c语言写的 就顺便改成了java 结果有点像爱心 还凑合着 你看看怎么样吧 哈5,如何用java在页面上用循环打印一个爱心形状import java.util.Scanner;public class test static void draw(int n)int i,j; for (i=1-(n>>1);i<=n;i++)if (i>0)for (j=0;j<i;j++) System.out.print(""); for (j=1;j<=2*(n-i)+1;j++)if (j==1||j==2*(n-i)+1) System.out.print(" *");else System.out.print("");System.out.println("\n");}elseif (i==0)System.out.print(" *");for (j=1;j<n;j++) System.out.print("");System.out.print(" *");for (j=1;j<n;j++) System.out.print("");System.out.print(" *\n");}elsefor (j=i;j<0;j++) System.out.print("");for (j=1;j<=n+2*i+1;j++)if (i==1-(n>>1)) System.out.print(" *");else if (j==1||j==n+2*i+1) System.out.print(" *");else System.out.print("");for (j=1;j<=-1-2*i;j++) System.out.print("");for (j=1;j<=n+2*i+1;j++)if (i==1-(n>>1)) System.out.print(" *");else if (j==1||j==n+2*i+1) System.out.print(" *");else System.out.print("");System.out.print("\n");}} public static void main(String[] args) System.out.println("Please input the size (n>=4):");Scanner sc = new Scanner(System.in);int n = sc.nextInt();draw(n);}}先说明这个不是我写的 是看了有人用C语言写的 就顺便改成了java 结果有点像爱心 还凑合着 你看看怎么样吧 哈你好!等看答案如果对你有帮助,望采纳 。

    推荐阅读