各位大神帮帮忙,有个朋友过生日 不知道如何用C语言编个生日蛋糕,能力有限,特来请教大神们
不是你能力有限,是C语言功能有限。C语言哪里能变出蛋糕来。
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);
}
#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();
}
照着你书本上打印倒三角的写法,自己搞搞,打印个蛋糕不就得了,要有耐心也可以自己手打空格和*啊,也能打印出来
是在程序里显示出来还是在cmd/shell里显示?是动态的还是静态的,很多C语言软件的图像显示(用户界面等)都是调用图像的哦
简陋一点的应该还是可以实现的
这个是打印字符串吗,想要好看一点的话要加图形库了
先用字符串编辑一个蛋糕图形文件
然然后读出显示
或者用画图软件画出蛋糕,转换成文字
想简单点就直接用“*”和空格慢慢打,想好看点就装EGE,用图形库来处理
z直接打印一个蛋糕就可以了,当然你可以使用线程一个*的连接起来
用vc做吧,贴个图就OK了,哈哈
你想要哪种的?是在网页显示还是控制台输出
可以用openGL做一个啊
`'.
.'
* .
: * *| :
' | || '|~'||'
'.
v~v~v~v
!@!@!@!
_!_!_!_!_
| || ||
| || |||
}{{{{}}}{{{
__||__
.'
* .
: * *| :
' | || '
`|~'||'
v~v~v~v
!@!@!@!
!!_!_!_
| || ||
| || |||
}{{{{}}}{{{
||
直接print("")......................
#include
int main()
{
printf_s(" iiiiiiiii\n");
printf_s(" | :H:a:p:p:y: |\n");
printf_s(" | _________ |__\n");
printf_s(" | ^^^^^^^^^^^^^^^^^ |\n");
printf_s(" | :B:i:r:t:h:d:a:y: |\n");
printf_s(" | |\n");
printf_s(" ~~~~~~~~~~~~~~~~~~~~~\n");
return 0;
}
找个蛋糕的字符画,将这个字符画保存为一个字符数组,再打印出来就可以了
来来来大家别吵
给你们看东西
看我博客可以画画得C++插件,你看看把
http://blog.csdn.net/huangzhengdoc/article/details/52470690
可以用图形库啊,如果用终端的话,用ncurses库试试
http://blog.csdn.net/marksinoberg/article/details/52116088
看看符合你的需求不。虽然不是C语言版本的。
字符串编辑一个蛋糕图形文件
然然后读出显示
或者用画图软件画出蛋糕,转换成文字
可以用Qt做,几行代码,放张图片就好了
最简单的就是输入打印一个蛋糕的形状
c语言用printf语句输出就行,\n换行。
推荐可以用asp 直接网页显示图片。
图形库要安装,太麻烦,用字符,可以搜索字符画,蛋糕
如果需要方便的使用图形库,可用HTML5 canvasHTML5 canvas
你可以弄一个满屏代码但是运行了显示是一个蛋糕的图案的数字串这样简单而且他也不知道你弄的什么
试过强行用printf来打印,后来用文本文档用字画好图形再去复制粘贴=-=
//sszg
#include
int main(){
printf("\'.\n .
\' * .\n: * *| :\n \' | || \'\n
|~\'||\'\n v~v~v~v\n !@!@!@!\n !!_!_!_\n| || ||\n| || |||\n}{{{{}}}{{{\n ||\n");
}
#include<stdio.h>
int main(){
printf("
`\'.\n .`\' ` * .\n: * *| :\n \' | || \'\n `|~\'||\'\n v~v~v~v\n !@!@!@!\n _!_!_!_!_\n| || ||\n| || |||\n}{{{{}}}{{{\n __||__\n");
}
书上是有例子的,照着来,改改字符就好了
还是画图比较好一些,代码这种还是缺乏新意
可以先去网上找一个由各种字符 拼出的蛋糕,再直接输出每行就行
iiiiiiiiii
|:H:a:p:p:y:|
|__________|__
|^^^^^^^^^^^^^^^^^|
| :B:i:r:t:h:d:a:y: |
| |