本帖最后由 jiujiukeji 于 2018-8-22 19:02 编辑
[PHP] 纯文本查看 复制代码 <?php
$str = [".",":","-","=","+","*","#","%","@"];
for ($y = 1.5; $y > -1.5;$y -= 0.1) {
for ($x = -1.5; $x < 1.5; $x += 0.05) {
$z = $x * $x + $y * $y - 1;
$f = $z * $z * $z - $x * $x * $y * $y * $y;
echo ($f <= 0 ? $str[(int)($f * -8)] : ' ');
}
echo PHP_EOL;
}
效果图:
附带js版
[JavaScript] 纯文本查看 复制代码 var str = [".",":","-","=","+","*","#","%","@"];
var love='';
var x=0,y=0,z=0;f=0,st='';
for (y = 1.5; y > -1.5;y -= 0.1) {
for (x = -1.5; x < 1.5; x += 0.05) {
z = x * x + y * y - 1;
f = z * z * z - x * x * y * y * y;
e=parseInt(f * -8);
love+=f <= 0 ? str[e] : ' ';
}
love+="\n";
}
console.log(love)
效果图:
再附python代码:
[Python] 纯文本查看 复制代码 str = [".", ":", "-", "=", "+", "*", "#", "%", "@"];
love = '';
for y in range(15, -15, -1):
for x in range(-150, 150, 5):
z = x / 100 * x / 100 + y / 10 * y / 10 - 1
f = z * z * z - x / 100 * x / 100 * y / 10 * y / 10 * y / 10
e = int(f * -8);
if f <= 0:
love += str[e];
else:
love += ' ';
love += '\r';
print(love)
效果图
再来一个走起
记得右键查看源代码 |