Python
使用Python的turtle库绘制一个简单的生日蛋糕动画:
```python
import turtle
def draw_cake(size):
t.pencolor("white")
t.begin_fill()
for i in range(360):
x = draw_x(size, i)
y = draw_y(size, i)
t.goto(x, y)
t.fillcolor("fef5f7")
t.end_fill()
def draw_x(size, angle):
x = size * math.cos(math.radians(angle))
y = size * math.sin(math.radians(angle))
return x
def draw_y(size, angle):
x = size * math.sin(math.radians(angle))
y = -size * math.cos(math.radians(angle))
return y
t = turtle.Turtle()
t.speed(0)
t.penup()
t.goto(-150, 90)
t.pendown()
draw_cake(150)
turtle.done()
```
C语言
使用C语言编写一个简单的生日祝福程序:
```c
include
int main() {
printf("生日快乐!\n");
printf("祝你在新的一岁中,健康快乐,事业顺利!\n");
printf("愿你的每一天都充满阳光和快乐!\n");
return 0;
}
```
C语言(带输入)
```c
include
int main() {
char name;
printf("请输入你的名字:");
scanf("%s", name);
printf("生日快乐,%s!\n", name);
printf("祝你在新的一岁中,健康快乐,事业顺利!\n");
printf("愿你的每一天都充满阳光和快乐!\n");
return 0;
}
```
C语言(带心形动画)
```c
include include include void Heart(); void GengXin(int); void Finish(int); int main(void) { int year; system("title 生日快乐!"); printf("请输入年份:"); scanf("%d", &year); GengXin(year); Finish(year); Heart(); printf(" :)\n"); Sleep(1000000000000000); return 0; } void Heart() { float x, y, a; for (y = 1.5; y > -1.5; y -= 0.1) { Sleep(100); for (x = -1.5; x < 1.5; x += 0.05) { a = x * x + y * y - 1; putchar(a * a * a - x * x * y * y * y <= 0.0 ? '*' : ' '); } } } void GengXin(int year) { printf("系统正在检测,请稍等……\n"); Sleep(1000); printf("已检测10%%……\n"); Sleep(100); } void Finish(int year) { printf("祝你生日快乐 %d 年!\n", year); } ``` Python(带图形界面) 使用Python的pygame库创建一个带有图形界面的生日祝福程序: