使用Python的turtle库
```python
import turtle
def draw_heart():
turtle.speed(1)
turtle.color('red')
turtle.begin_fill()
turtle.left(140)
turtle.forward(224)
turtle.circle(-112, 200)
turtle.left(120)
turtle.circle(-112, 200)
turtle.forward(224)
turtle.end_fill()
turtle.hideturtle()
turtle.done()
draw_heart()
```
使用Python的matplotlib库
```python
import numpy as np
import matplotlib.pyplot as plt
t = np.linspace(0, 2 * np.pi, 1000)
x = 16 * np.sin(t)3
y = 13 * np.cos(t) - 5 * np.cos(2*t) - 2 * np.cos(3*t) - np.cos(4*t)
plt.figure(figsize=(8, 6))
plt.plot(x, y, color='red')
plt.fill(x, y, color='red', alpha=0.6)
plt.title('Python', fontsize=18)
plt.axis('equal')
plt.grid(True)
plt.show()
```
使用C语言
```c
include
int main() {
int i, j;
for (i = 0; i < 5; i++) {
for (j = 0; j < 5 - i; j++) {
printf("*");
}
printf("\n");
}
for (i = 0; i < 5; i++) {
for (j = 0; j < i; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
```
这些代码示例分别使用Python的turtle库、matplotlib库和C语言来绘制爱心。你可以根据自己的喜好和编程环境选择合适的方法。