赞
踩
程序猿们,圣诞节快到啦!看看我制作的圣诞树+带名字的爱心。你们的朋友是不是在找你们要或者你们想给对方发圣诞树了呀。苦于不会画画,我们不知道该怎么拿出合适的祝福。程序猿有程序猿的浪漫,不会画画的我们照样可以敲出浪漫~
本来想在这篇文章上给大家看看效果的,但鄙人学艺不精目前不知道视频怎么放到博客上去,请小伙伴们移步到我个人动态上去观看,我的她看到以后整个人都爱住了都。
话不多说,先上圣诞树的代码。以下代码主要学习于另一位博主id:Emily-c。
目录
- #include <math.h>
- #include <stdio.h>
- #include <time.h>
- #include <windows.h>
- #include <stdlib.h>
-
- #define PI 3.14159265359
-
- float sx, sy;
-
- float sdCircle(float px, float py, float r)
- {
- float dx = px - sx, dy = py - sy;
-
- return sqrtf(dx * dx + dy * dy) - r;
-
- }
-
- float opUnion(float d1, float d2)
- {
- return d1 < d2 ? d1 : d2;
-
- }
-
- #define T px + scale * r * cosf(theta), py + scale * r * sin(theta)
-
- float f(float px, float py, float theta, float scale, int n)
- {
- float d = 0.0f;
-
- for (float r = 0.0f; r < 0.8f; r += 0.02f)
-
- d = opUnion(d, sdCircle(T, 0.05f * scale * (0.95f - r)));
-
- if (n > 0)
-
- for (int t = -1; t <= 1; t += 2)
- {
- float tt = theta + t * 1.8f;
-
- float ss = scale * 0.9f;
-
- for (float r = 0.2f; r < 0.8f; r += 0.1f)
- {
- d = opUnion(d, f(T, tt, ss * 0.5f, n - 1));
-
- ss *= 0.8f;
-
- }
-
- }
-
- return d;
-
- }
- int main(int argc, char* argv[])
- {
- int n = argc > 1 ? atoi(argv[1]) : 3;
-
- for (sy = 0.8f; sy > 0.0f; sy -= 0.02f, putchar('\n'))
-
- for (sx = -0.35f; sx < 0.35f; sx += 0.01f)
-
- putchar(f(0, 0, PI * 0.5f, 1.0f, n) < 0 ? '*' : ' ');
- }

小白大都看不懂,复制粘贴就对啦。觉得圣诞树好看的话记得点赞加收藏哦!
接下来上带有爱心名字的代码,代码段可以加在int main()里哦,对于小白来说可谓是极度舒适,万能printf(),come on!
- printf(" ******** ******** \n");
- Sleep(200);
- printf(" ***************************** \n");
- Sleep(200);
- printf(" ****** *************** ******* \n");
- Sleep(200);
- printf(" ******* ****************** ********** \n");
- Sleep(200);
- printf(" ****** **************** *********** \n");
- Sleep(200);
- printf(" **** *********** ***** \n");
- Sleep(200);
- printf(" *************************** \n");
- Sleep(200);
- printf(" *********************** \n");
- Sleep(200);
- printf(" ******************* \n");
- Sleep(200);
- printf(" *************** \n");
- Sleep(200);
- printf(" *********** \n");
- Sleep(200);
- printf(" ******* \n");
- Sleep(200);
- printf(" *** \n");
- Sleep(2000);
-
- printf("\n");
- printf("\n");
- Sleep(2000);
- printf("别人有的圣诞树你也得有,提前祝ruruzi.,圣诞快乐吖!\n");
- printf("\n");
- printf("\n");
- Sleep(2000);
- printf("Merry Christmas!!!!!\n");
- printf("\n");
- printf("\n");
- Sleep(2000);
- printf(" by-施律.");
- return 0;

睡眠函数Sleep()至关重要,其头文件是 windows.h. 它直接影响到你录制视频时候的美观性!
Sleep()括号里的是以毫秒来作单位的,比如说Sleep(1000)就是让系统睡眠1秒,200就是0.
2秒,具体你想让视频呈现的如何由你掌控。接下来就不一一列举啦。
录屏软件我推荐大家用嗨格式录屏软件。能免费进行录制的哦。
感谢能观看到这的你,以上就是圣诞礼物代码,如果这篇文章对你有帮助的话,请留下你的收藏与点赞哦。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。