求大神帮忙,用C语言写个生日蛋糕出来

各位大神帮帮忙,有个朋友过生日 不知道如何用C语言编个生日蛋糕,能力有限,特来请教大神们

4

31个回答

不是你能力有限,是C语言功能有限。C语言哪里能变出蛋糕来。

28
qq_34785270
qq_34785270 就是通过一些代码 然后运行之后显示出来看起来像蛋糕。
大约 3 年之前 回复
 #include <stdlib.h>
#include <math.h>
#include <graphics.h>
int size, color = 1;
void *save1, *save2;
void save();
void dsnow();
void font();
struct Snow
{
int x;
int y;
int speed;
} snow[100];
void save()
{
int i, x, y;
setcolor(WHITE);
for (i = 1; i <= 6; i++)
{
x = 200+5 * sin(i *3.1415926 / 3);
y = 200-5 * cos(i *3.1415926 / 3);
line(200, 200, x, y);
}
size = imagesize(195, 195, 205, 205);
save1 = malloc(size);
save2 = malloc(size);
getimage(195, 195, 205, 205, save1);
getimage(100, 100, 110, 110, save2);
}
void font()
{
setcolor(color);
settextstyle(0, 0, 4);
outtextxy(80, 200, "HAPPPY NEW YEAR");
color++;
if (color > 15)
color =1;
}
void dsnow()
{
int a[66], i, num = 0;
randomize();
for (i = 0; i < 66; i++)
a[i] = (i - 2) *10;
cleardevice();
while (!kbhit())
{
font();
if (num != 100)
{
snow[num].speed = 2+random(10);
i = random(66);
snow[num].x = a[i];
snow[num].y = 0;
}
for (i = 0; i < num; i++)
putimage(snow[i].x, snow[i].y, save2, COPY_PUT);
font();
if (num != 100)
num++;
for (i = 0; i < num; i++)
{
snow[i].y += snow[i].speed;
putimage(snow[i].x, snow[i].y, save1, COPY_PUT);
if (snow[i].y > 500)
snow[i].y = 0;
}
}
}
main()
{
int gdriver = DETECT, gmode;
initgraph(&gdriver, &gmode, "");
save();
dsnow();
getch();
closegraph();
}
12
weixin_44638824
一抹微笑、”“很苦涩 如何执行啊
5 个月之前 回复
Bear_861110453
cug_xy 回复this_zq: 因为你没有这个文件 百度可以下载到得吧
接近 3 年之前 回复
qinyf2015
QQ玉 回复this_zq: graphics.h是turboc专有的,VC 里没有的。用graphics.h必须用turboc
接近 3 年之前 回复
this_zq
this_zq 大神,为什么#include <graphics.h>这个显示错误,我执行的时候。。
接近 3 年之前 回复
qq_33578343
陌上人已老 我只懂一点图形库,你的这个程序我运行了一下,第25行有点问题
大约 3 年之前 回复

void welcome()
{
int b,k=4;
b=200;
PlaySound("srg.wav", NULL, SND_FILENAME|SND_ASYNC );
while(k)
{
system("color c");
printf("+ + + + + + + + + + + + + + + + + + + + + + + + + + +\n");
printf("\t袁\n\n");
printf("\t\t\t * \n");
printf("\t\t\t | \n");
printf("\t\t\t ooooo \n");
printf("\t\t\t | | | | \n");
printf("\t\t\tooooooooooooooo\n");
printf("\t\t\t| 日 快 乐 |\n");
printf("\t\t\t|_____________|\n\n");
printf("\nHAPPY BIRTHDAY!\n\n");
printf("× × × × × × × × × × × × × × × × × × × × × × × × × × ×\n");
printf("醉月思制作 ");
Sleep(b);
system("cls");

    system("color e");
    printf("× × × × × × × × × × × × × × × × × × × × × × × × × × ×\n");
    printf("\t袁\t新\n\n");
    printf("\t\t\t               \n");
    printf("\t\t\t       |       \n");
    printf("\t\t\t  *  ooooo  *  \n");
    printf("\t\t\t  |  |   |  |  \n");
    printf("\t\t\tooooooooooooooo\n");
    printf("\t\t\t| 生    快 乐 |\n");
    printf("\t\t\t|_____________|\n\n");
    printf("\n\tHAPPY BIRTHDAY!\n\n");
    printf("+ + + + + + + + + + + + + + + + + + + + + + + + + + +\n");
    printf("醉月思制作");
    Sleep(b);
    system("cls");

    system("color 9");
    printf("+ + + + + + + + + + + + + + + + + + + + + + + + + + +\n");
    printf("\t袁\t新\t颖\n\n");
    printf("\t\t\t       *       \n");
    printf("\t\t\t       |       \n");
    printf("\t\t\t  *  ooooo  *  \n");
    printf("\t\t\t  |  |   |  |  \n");
    printf("\t\t\tooooooooooooooo\n");
    printf("\t\t\t| 生 日    乐 |\n");
    printf("\t\t\t|_____________|\n\n");
    printf("\n\t\tHAPPY BIRTHDAY!\n\n");
    printf("× × × × × × × × × × × × × × × × × × × × × × × × × × ×\n");
    printf("醉月思制作");
    Sleep(b);
    system("cls");

    system("color a");
    printf("× × × × × × × × × × × × × × × × × × × × × × × × × × ×\n");
    printf("\t袁\t新\t颖\t生\n\n");
    printf("\t\t\t               \n");
    printf("\t\t\t       |       \n");
    printf("\t\t\t     ooooo     \n");
    printf("\t\t\t  |  |   |  |  \n");
    printf("\t\t\tooooooooooooooo\n");
    printf("\t\t\t| 生 日 快    |\n");
    printf("\t\t\t|_____________|\n\n");
    printf("\n\t\t\tHAPPY BIRTHDAY!\n\n");
    printf("+ + + + + + + + + + + + + + + + + + + + + + + + + + +\n");
    printf("醉月思制作");
    Sleep(b);
    system("cls");

    system("color c");
    printf("+ + + + + + + + + + + + + + + + + + + + + + + + + + +\n");
    printf("\t袁\t新\t颖\t生\t日\n\n");
    printf("\t\t\t       *       \n");
    printf("\t\t\t       |       \n");
    printf("\t\t\t     ooooo     \n");
    printf("\t\t\t  |  |   |  |  \n");
    printf("\t\t\tooooooooooooooo\n");
    printf("\t\t\t| 生          |\n");
    printf("\t\t\t|_____________|\n\n");
    printf("\n\t\t\t\tHAPPY BIRTHDAY!\n\n");
    printf("× × × × × × × × × × × × × × × × × × × × × × × × × × ×\n");
    printf("醉月思制作");
    Sleep(b);
    system("cls");

    system("color e");
    printf("× × × × × × × × × × × × × × × × × × × × × × × × × × ×\n");
    printf("\t袁\t新\t颖\t生\t日\t快\n\n");
    printf("\t\t\t               \n");
    printf("\t\t\t       |       \n");
    printf("\t\t\t  *  ooooo  *  \n");
    printf("\t\t\t  |  |   |  |  \n");
    printf("\t\t\tooooooooooooooo\n");
    printf("\t\t\t|    日       |\n");
    printf("\t\t\t|_____________|\n\n");
    printf("\n\t\t\t\t\tHAPPY BIRTHDAY!\n\n");
    printf("+ + + + + + + + + + + + + + + + + + + + + + + + + + +\n");
    printf("醉月思制作");
    Sleep(b);
    system("cls");

    system("color 9");
    printf("+ + + + + + + + + + + + + + + + + + + + + + + + + + +\n");
    printf("\t袁\t新\t颖\t生\t日\t快\t乐\n\n");
    printf("\t\t\t       *       \n");
    printf("\t\t\t       |       \n");
    printf("\t\t\t  *  ooooo  *  \n");
    printf("\t\t\t  |  |   |  |  \n");
    printf("\t\t\tooooooooooooooo\n");
    printf("\t\t\t|       快    |\n");
    printf("\t\t\t|_____________|\n\n");
    printf("\n\t\t\t\t\t\tHAPPY BIRTHDAY!\n\n");
    printf("× × × × × × × × × × × × × × × × × × × × × × × × × × ×\n");
    printf("醉月思制作");
    Sleep(b);
    system("cls");

    system("color a");
    printf("× × × × × × × × × × × × × × × × × × × × × × × × × × ×\n");
    printf("\t袁\t新\t颖\t生\t日\t快\t乐\t!\n\n");
    printf("\t\t\t               \n");
    printf("\t\t\t       |       \n");
    printf("\t\t\t     ooooo     \n");
    printf("\t\t\t  |  |   |  |  \n");
    printf("\t\t\tooooooooooooooo\n");
    printf("\t\t\t|          乐 |\n");
    printf("\t\t\t|_____________|\n\n");
    printf("\n\t\t\t\t\t\t\tHAPPY BIRTHDAY!\n\n");
    printf("+ + + + + + + + + + + + + + + + + + + + + + + + + + +\n");
    printf("醉月思制作");
    Sleep(b);
    system("cls");
    k--;
}
 Sleep(5000);

}

12
zfs1994
夜雨灬闻铃 只能说,666
接近 3 年之前 回复

照着你书本上打印倒三角的写法,自己搞搞,打印个蛋糕不就得了,要有耐心也可以自己手打空格和*啊,也能打印出来

8
qq_34785270
qq_34785270 嗯哪,这个是可以的,就是想寻求下有没有简单点的方法
大约 3 年之前 回复

先用字符串编辑一个蛋糕图形文件
然然后读出显示
或者用画图软件画出蛋糕,转换成文字

1

用vc做吧,贴个图就OK了,哈哈

1

是在程序里显示出来还是在cmd/shell里显示?是动态的还是静态的,很多C语言软件的图像显示(用户界面等)都是调用图像的哦

0

简陋一点的应该还是可以实现的

0

这个是打印字符串吗,想要好看一点的话要加图形库了

0

z直接打印一个蛋糕就可以了,当然你可以使用线程一个*的连接起来

0
共31条数据 1 3 4 尾页
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!