devc++生日祝福代码
时间: 2023-10-26 19:06:55 浏览: 108
生日祝福代码可以通过以下方式来实现:
```C
#include <stdio.h>
int main() {
char name[20];
int age;
printf("请输入名字: ");
scanf("%s", name);
printf("请输入年龄: ");
scanf("%d", &age);
printf("生日快乐,%s!祝你%d岁生日快乐,健康快乐成长!\n", name, age);
return 0;
}
```
相关问题
devc++生日烟花代码
根据提供的引用内容,以下是一个简单的Dev-C++生日烟花代码示例:
```c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
void drawFirework() {
int x, y, i, j, k, color;
for (i = 0; i < 20; i++) {
x = rand() % 70 + 10;
y = rand() % 10 + 10;
color = rand() % 7 + 9;
for (j = 0; j < 5; j++) {
for (k = 0; k < 5; k++) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
printf("\033[%d;%dH*", y + j, x + k);
}
}
}
}
int main() {
srand(time(NULL));
int i;
for (i = 0; i < 10; i++) {
drawFirework();
Sleep(1000);
system("cls");
}
return 0;
}
```
这个代码使用了Windows API中的SetConsoleTextAttribute函数来改变控制台输出的颜色,从而实现了烟花的效果。它使用了rand函数来生成随机的位置和颜色,并使用循环来绘制每个烟花。在主函数中,它使用了Sleep函数来延迟显示下一个烟花,并使用system函数来清空控制台输出。
devc++生日蛋糕代码
以下是 devc++ 中绘制生日蛋糕的代码:
```c++
#include <graphics.h>
#include <conio.h>
int main()
{
initgraph(640, 480); // 初始化绘图窗口
setbkcolor(WHITE); // 设置背景颜色为白色
cleardevice(); // 清空绘图窗口
// 绘制蛋糕底部
setfillcolor(YELLOW); // 设置填充颜色为黄色
solidpie(320, 400, 0, 360, 200); // 绘制实心扇形
setfillcolor(WHITE); // 设置填充颜色为白色
solidpie(320, 400, 0, 360, 180); // 绘制实心扇形
// 绘制蛋糕顶部
setfillcolor(RED); // 设置填充颜色为红色
solidpie(320, 250, 0, 360, 150); // 绘制实心扇形
setfillcolor(WHITE); // 设置填充颜色为白色
solidpie(320, 250, 0, 360, 130); // 绘制实心扇形
// 绘制蜡烛
setfillcolor(YELLOW); // 设置填充颜色为黄色
solidrectangle(310, 200, 330, 250); // 绘制实心矩形
setfillcolor(RED); // 设置填充颜色为红色
solidcircle(320, 190, 20); // 绘制实心圆形
getch(); // 等待用户按键
closegraph(); // 关闭绘图窗口
return 0;
}
```