Python3 >>> print('\n'.join([''.join([('Love'[(x-y)%4]if((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3<=0 else' ')for x in range(-30,30)])for y in range(15,-15,-1)])) veLoveLov veLoveLov eLoveLoveLoveLove eLoveLoveLoveLove veLoveLoveLove
看到一行Python写的代码,会用LovePython输出心形: print('\n'.join([''.join([('LovePython'[(x-y)%10]if((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3<=0 else' ')for x in range(-30,30)])for y in range(15,-15,-1)])) 尝试用js复现一遍如下: var str = 'I Love You';var res = "
在网上无意中看到这个代码,学习了一下心形函数的知识:http://mathworld.wolfram.com/HeartCurve.html package dada; /** * 了解Heart Curve函数中的 一种:(X的平方+Y的平方-1)-X的平方乘以Y的三次方 */ public class HeartTest { public static void main(String[] args) { //i对应X j对应Y for (float i = 1.5f; i > -1.5f;