怎么用java编写一个爱心

怎么用java编写一个爱心,第1张

分析:

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

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

2在或者,长得不太像- -

Systemoutprintln("       ");

for (int i = 4; i < 10; i++) {

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

Systemoutprint(" ");

}

for (int b = 1; b <= 2 9 - 2 i - 1; b++) { 

Systemoutprint("");

}

Systemoutprint("\n");

}

 

用方程的话肯定输出不会和你的图完全一致

心形线方程如图

用上面行第二个比较简单,程序如下

#include <stdioh>

bool draw(float x, float y)

{

 float a = x  x + y  y - 10;

 float b = x  x  y  y  y;

 return a  a  a - b <= 0;

}

int main(int argc, char argv[])

{

 for (float y = 15; y >= -15; y -= 01)

 {

  for (float x = -12; x <= 12; x += 005)

  {

   if (draw(x, y))

   {

    bool left = draw(x - 005, y);

    bool right = draw(x + 005, y);

    bool up = draw(x, y + 01);

    bool down = draw(x, y - 01);

    if (left && right && up && down)

     printf(" ");

    else

     printf("");

   }

   else

    printf(" ");

  }

  printf("\n");

 }

 return 0;

}

draw函数是判断(x,y)坐标是否在心形范围内

主函数循环,y取值±15之间,步长01,x取值±12之间,步长005

如果(x,y)坐标在心形范围外打印空格

如果(x,y)坐标在心形范围内,由于这个心是空心的,要继续判断是不是心形边缘,判断周围4个点坐标,如果都在范围内,表示(x,y)坐标不会是边缘,打印空格,否则是边缘,打印星号

最终结果如图

1发送xoxO(会出现满屏亲亲) 2发送mi manchi(会出现满屏小星星) 3发送ohh(翻译:留在我身边) 4发送ch will mit dir S wim(翻译:我想和你在一起) 5发送Voce e meu bebe(翻译:你是我的宝贝) 6发送 RUYDUAautrinuU(翻译我只喜欢你) 7发送 love at first sight(翻译:—见钟情) 8发送We will be happy(我们会幸福) 9发送missu(会出现星星雨) 10发送u621u7231u460(翻译:爱你) 11发送u5728u4e0Ou8d7Nu5427(翻译在一起) 12发送Milji pouze jednu osobu, ta osoba jste vy我只爱一个人,那个人就是你) 13发送 yax you(翻译我跟你说)发送yyyax you翻译我喜欢你)发送 yox you!(我爱死你了) 14n 55 iw!(倒过来是i miss you我想你。) 15我想要两颗西柚("1 wanttoseeyou"我想要见你) 16962464(用九宫格输入试试) 17Mg+Znso4==MgSo4+zn(你的镁夺走了我的锌) 18Te echo de menos(微信翻译:我想你) 19双木非林田下有心(相思) 20nnggui(倒过来看就是ineedyoy我需要你) 表白代码大全可复制免费2  程序员的表白代码 第一条语言:Java代码翻译:直到死之前,每天爱你多一点代码:while(lifeend){love++;} 第二条语言:C语言代码翻译:IcannotsayHellototheWorldwithoutu代码:#incldestdiohintmain(){printf(HelloWorldn);retrn0;}//IcannotsayHellototheWorldwithoutu 第三条语言:python代码翻译:山无陵,江水为竭,冬雷震震,夏雨雪,天地合,乃敢与君绝!代码:if(mountainarris==None):if(riverwater==None):if(winterthunder==True):if(summersnow== True):if(skyheight==groundheight):iwithyou=Falseelse:iwithyou=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#personname])see_you_next_world(Name)-one_world(Name) 第五条语言:Java语言代码翻译:爱你到天荒地老代码:while(!worlddestroy){Systemoutprintln(iloveyou);} 表白代码大全可复制免费3  第一条 语言:Java 代码翻译: 直到死之前,每天爱你多一点 代码: while (life < end) { love++; } // I can not say Hello to the World without u  第二条 语言:python 代码翻译: 山无陵, 江水为竭, 冬雷震震, 夏雨雪, 天地合, 乃敢与君绝! 代码: if(mountainarris==None): if(riverwater==None): if(winterthunder==True): if(summersnow==True): if(skyheight==groundheight): iwithyou=False else: iwithyou=True one_world(Name)  第三条 语言:Java语言 代码翻译: 爱你到天荒地老 代码: while(!worlddestroy){ Systemoutprintln("i love you"); }  第四 条 语言:C语言 代码翻译: 两隔的`世界; 无名的信件; 短暂的停留; 长久的记忆; 说这么多,只是想说:我想你了。 代码: #include int main() { double world; unsigned letter; short stay; long memories; printf("I miss you "); return 0; }

欢迎分享,转载请注明来源:表白网

原文地址:https://h5.hunlipic.com/biaobai/3568766.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2024-03-09
下一篇2024-03-09

发表评论

登录后才能评论

评论列表(0条)

    保存