分析:
首先爱心分成两半前面三行左右一样右边就可以通过左边反相得到
中间两行是个长方形,剩下的就是个倒等腰三角形
System.out.println(" ? ? ?** **");
for (int a = 0; a i; a++) {
System.out.print(" ");
}
System.out.print("*");
System.out.print("\n");
** ?**
*********
*******
*****
***
*
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");
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代码输出心的形状
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);}
把如下代码加入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代码生成爱心相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!