网站首页 > 文章中心 > 其它

JAVA代码生成爱心

作者:小编 更新时间:2023-12-05 12:37:44 浏览量:472人看过

怎么用java编写一个爱心

分析:

首先爱心分成两半前面三行左右一样右边就可以通过左边反相得到

中间两行是个长方形,剩下的就是个倒等腰三角形

System.out.println(" ? ? ?** **");

for (int a = 0; a i; a++) {

System.out.print(" ");

JAVA代码生成爱心-图1

}

System.out.print("*");

System.out.print("\n");

** ?**

JAVA代码生成爱心-图2

*********

*******

*****

***

*

如何用java在页面上用循环打印一个爱心形状

import java.util.Scanner;

public class test{

static void draw(int n)

{

int i,j;

for (i=1-(n1);i=n;i++)

if (i0)

for (j=0;ji;j++) System.out.print(" ");

else System.out.print(" ");

System.out.println("\n");

JAVA代码生成爱心-图3

else

if (i==0)

System.out.print(" *");

for (j=1;jn;j++) System.out.print(" ");

System.out.print(" *\n");

for (j=i;j0;j++) System.out.print(" ");

if (i==1-(n1)) System.out.print(" *");

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int n = sc.nextInt();

draw(n);

}先说明这个不是我写的 是看了有人用C语言写的 就顺便改成了java 结果有点像爱心 还凑合着 你看看怎么样吧 哈

用java代码怎么输出心的形状

用java代码输出心的形状

public class CartesianCurve extends Applet{

int width, height;

Image image;

Graphics draw_Curve;

public void init(){

setBackground(Color.black);

width = getSize().width;

height = getSize().height;

image = createImage(width, height);

draw_Curve = image.getGraphics();

public void paint(Graphics g){

draw_Curve.clearRect(0, 0, width, height);

draw_Curve.setColor(Color.red);

int i, j;

double x, y, r;

g.drawImage(image, 0, 0, this);

程序员的表白代码

程序员的表白代码

第一条语言:Java代码翻译:直到死之前,每天爱你多一点代码:while(lifeend){love++;}

第二条语言:C语言代码翻译:IcannotsayHellototheWorldwithoutu.代码:#incldestdio.hintmain(){printf(HelloWorldn);retrn0;}//IcannotsayHellototheWorldwithoutu.

第三条语言:python代码翻译:山无陵,江水为竭,冬雷震震,夏雨雪,天地合,乃敢与君绝!代码:if(mountain.arris==None):if(river.water==None):if(winter.thunder==True):if(summer.snow==True):if(sky.height==ground.height):i.withyou=Falseelse:i.withyou=True.

第四条语言:Erlang代码代码翻译:深圳相遇,至死不渝代码:-module(you_and_me).-export([start/1]).-record(person,{name,address,status}).start(Name)-one_world(Name).one_world(Name)keep_to_love_you(Person).say_goodbye(Person)-io:format(~p:seeyounextworld!~n,[Person#person.name]).see_you_next_world(Name)-one_world(Name).

第五条语言:Java语言代码翻译:爱你到天荒地老代码:while(!world.destroy){System.out.println(iloveyou);}

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 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 (sizeendSize){

eval(zoomText)

eval(zoomSize)

eval(closeIt)

setTimeout("zoom("+num+",'"+fn+"')",Zspeed)

}else{

eval(fn);

function fadeIt(num){

if (numnumColors){

eval(fadeColor)

num+=1;

setTimeout("fadeIt("+num+")",Cspeed)

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(numnumText){

zoom(num,'go('+gonum+')')

fadeIt(0)

/script

java爱心代码运行爱心扭曲是怎么回事

java爱心代码运行爱心扭曲是因为:

①.、java爱心代码的其中一行出现了错误.

以上就是土嘎嘎小编为大家整理的JAVA代码生成爱心相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章