java愛心
把如下代碼加入<body>區域中
<style type="text/css">
body
{
background-color:#FFFFFF;
font-family: Arial;
font-size:10pt;
}
</style>
<script>
text=new Array('www','njcatv','net','需要放大的
/\/\
\ /
\/
文字')
var numText=4
color=new Array('#000000','#2F2F2F','#4F4F4F','#7F7F7F','#408080')
var numColors=5
var endSize=70
var Zspeed=30
var Cspeed=200
var font='Arial Black'
var hide=false
var size=10
var gonum=0
var ie, n;
if (document.all) {
n=0
ie=1
zoomText='document.all.zoom.innerText=text[num]'
zoomSize='document.all.zoom.style.fontSize=size'
closeIt=""
fadeColor="document.all.zoom.style.color=color[num]"
}
if (document.layers) {
n=1;ie=0
zoomText=""
zoomSize="document.zoom.document.write('<p align=\"center\" style=\"font-family:'+font+'; font-size:'+size+'px; color:'+color[0]+'\">'+text[num]+'</p>')"
closeIt="document.zoom.document.close()"
fadeColor="document.zoom.document.write('<p align=\"center\" style=\"font-family:'+font+'; font-size:'+endSize+'px; color:'+color[num]+'\">'+text[numText-1]+'</p>')"
}
function zoom(num,fn){
if (size<endSize){
eval(zoomText)
eval(zoomSize)
eval(closeIt)
size+=5;
setTimeout("zoom("+num+",'"+fn+"')",Zspeed)
}else{
eval(fn);
}
}
function fadeIt(num){
if (num<numColors){
eval(fadeColor)
eval(closeIt)
num+=1;
setTimeout("fadeIt("+num+")",Cspeed)
}else{
hideIt()
}
}
function hideIt(){
if(hide){
if(ie)document.all.zoom.style.visibility="hidden"
if(n)document.layers.zoom.visibility="hidden"
}
}
function init(){
if(ie){
document.all.zoom.style.color=color[0]
document.all.zoom.style.fontFamily=font
}
if(ie || n) go(0)
}
function go(num){
gonum+=1
size=10
if(num<numText){
zoom(num,'go('+gonum+')')
}else{
fadeIt(0)
}
}
</script>
<div id="zoom" align="center" style="position:absolute; top:150">
『貳』 java 用*畫個心形
要實心的還是空心的,如果是實心的用循環嵌套,列循環中嵌套行的循環就可以了
『叄』 怎麼用java編寫一個愛心
分析:
首先愛心分成兩半前面三行左右一樣右邊就可以通過左邊反相得到
中間兩行是個長方形,剩下的就是個倒等腰三角形
2.在或者,長得不太像- -
System.out.println(" ** **");
for (int i = 4; i < 10; i++) {
for (int a = 0; a < i; a++) {
System.out.print(" ");
}
for (int b = 1; b <= 2 * 9 - 2 * i - 1; b++) {
System.out.print("*");
}
System.out.print(" ");
}
** **
*********
*******
*****
***
*
『肆』 java 繪制圖形——愛心。
想泡妞還不想下功夫,這個堅決不能告訴你 。。
『伍』 如何用java中的for輸出心形
public class Test{
static float count(float x, float y) {
(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("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
System.out.println();
}
public static void main(String[] args) {
printEmpty();
}
}
『陸』 如何用java畫出心形
最簡單的system.out.print();
自己多列印幾次試試就好了
『柒』 for語句 輸出心形(java)
for語句輸出心形(java)的方法如下:
使用eclipse,創建一個Java文件命名為Test.java
(7)java愛心擴展閱讀:
for 語句表達式:
表達式1:一般為賦值表達式,給控制變數賦初值;
表達式2:關系表達式或邏輯表達式,循環控制條件;
表達式3:一般為賦值表達式,給控制變數增量或減量。
『捌』 Java 心形圖形
public class Heart {
public static void main(String[] args) {
int size = 4;
int number = 7;
for (int i = 0; i <= size; i++) {
for (int j = 4; j <= 4 - i; j--)//變數j一直自減 最後是負數的時候也滿足條件 所以無限循環了
System.out.print(" ");
for (int j = 1; j <= i; j++)//
System.out.print("*");
for (int j = size; j <= size - i; j--)//變數j一直自減1 最後是負數的時候也滿足條件 所以無限循環了
System.out.print(" ");
for (int j = 1; j <= i; j++)
System.out.print("*");
System.out.println();
}
for (int k = number; k <= number; k--) {
System.out.print("*");
System.out.println();
}
}
}
『玖』 java如何畫出愛心
這個成不
1.首先獲取愛心的數學表達式(函數);
2.然後Bitmap bit=new Bitmap(32,32);Graphics g=Graphics.FromImage(bit);
3.確定一個開始點startPoint,根據函數遞歸所有點,畫出愛心。
『拾』 如何用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");
}
else
if (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");
}
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 結果有點像愛心 還湊合著 你看看怎麼樣吧 哈