C语言 生日代码

C语言 生日代码这篇文章主要介绍了 C 语言编写的生日代码 包括了代码的具体实现以及如何改变爱心颜色的方法 希望这份代码能够帮助读者制作一份让 TA 感到高兴的生日礼物

大家好,欢迎来到IT知识分享网。

 我发现还是挺多人收藏这篇博客的,于是乎重新编写了一下,看起来没这么拥挤冗余,但是编码能力有限,很多地方无从下手,无法进一步压缩代码。

 希望这篇博客能够帮助到你们,让这份代码让你想送给的TA感到高兴。 

#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <Windows.h> #include <stdlib.h> #include <string.h> 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(0000); 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 ? '*' : ' '); } putchar('\n'); } } void GengXin(int year) { printf("系统正在检测,请稍等……\n"); Sleep(1000); printf("已检测10%%……\n"); Sleep(100); printf("已检测20%%……\n"); Sleep(100); printf("已检测40%%……\n"); Sleep(100); printf("已检测60%%……\n"); Sleep(300); printf("已检测80%%……\n"); Sleep(300); printf("已检测90%%……\n"); Sleep(500); printf("已检测99%%……\n"); Sleep(1000); printf("已检测100%%……\n"); Sleep(100); printf("检测完成\n"); printf("恭喜您!完成为期一年的生活副本\n"); Sleep(1000); printf("为感谢各位玩家长期以来对地球OL的大力支持,现发放额外奖励\n"); Sleep(1000); printf("正在发放奖励…\n"); Sleep(1000); printf("本次奖励发放如下:\n"); Sleep(1000); printf("1. 获得健康BUFF,提高身体恢复速度\n"); Sleep(500); printf("2. 永久获得活力加成,时刻获得好心情\n"); Sleep(600); printf("3. 幸运值MAX\n"); Sleep(700); printf("4. 快递无需等待\n"); Sleep(800); printf("5. 获得双倍金币加成\n"); Sleep(1000); printf("奖励发放完毕…进行版本更新检测…\n"); Sleep(2000); printf("发现新的版本 LIFE V%d\n", year); Sleep(1000); printf("正在下载更新内容……\n"); Sleep(3000); printf("本次更新预计用时1个月,届时开启新的副本和任务,感谢各位的支持……\n"); Sleep(1500); } // 完成结束行,末尾可自行修改名字 void Finish(int year) { printf("#:/C:\\Program Files (x86)\\InstallShield Installation Information\\{DA5623C3-0F05-4B6F-AB90-743A279EC8F8}\\0x040a\n"); Sleep(500); printf("#/C:\\Program Files (x86)\\InstallShield Installation Information\\{DA5623C3-0F05-4B6F-AB90-743A279EC8F8}\\0x040b\n"); Sleep(200); printf("#/C:\\Program Files (x86)\\InstallShield Installation Information\\{DA5623C3-0F05-4B6F-AB90-743A279EC8F8}\\setup\n"); Sleep(200); printf("#/C:\\Program Files (x86)\\InstallShield Installation Information\\{DA5623C3-0F05-4B6F-AB90-743A279EC8F8}\\1053.mat\n"); Sleep(200); printf("#/C:\\Program Files (x86)\\InstallShield Installation Information\\{DA5623C3-0F05-4B6F-AB90-743A279EC8F8}\\0x04113\n"); printf("\n\n\n\n"); Sleep(200); printf("#/You cannot improve your past, but you can improve your future. Once time is wasted, life is wasted.\n"); Sleep(200); printf("#/Knowlegde can change your fate and English can accomplish your future. \n"); Sleep(200); printf("#If you do not learn to think when you are young, you may never learn. ( Edison ) \n"); Sleep(200); printf("#Dont aim for success if you want it; just do what you love and believe in, and it will come naturally. \n"); Sleep(200); printf("#/If there were less sympathy in the world, there would be less trouble in the world. ( O. Wilde ) \n"); Sleep(200); printf("\n"); printf("#/C:\\Program Files (x86)\\InstallShield Installation Information\\{DA5623C3-0F05-4B6F-AB90-743A279EC8F8}\\0x04113\n"); Sleep(200); printf("#/C:\\Program Files (x86)\\InstallShield Installation Information\\{DA5623C3-0F05-4B6F-AB90-743A279EC8F8}\\0x04113\n"); Sleep(200); printf("#/C:\\Program Files (x86)\\InstallShield Installation Information\\{DA5623C3-0F05-4B6F-AB90-743A279EC8F8}\\0x04113\n"); Sleep(200); printf("#/C:\\Program Files (x86)\\InstallShield Installation Information\\{DA5623C3-0F05-4B6F-AB90-743A279EC8F8}\\0x04113\n"); Sleep(200); printf("#/C:\\Program Files (x86)\\InstallShield Installation Information\\{DA5623C3-0F05-4B6F-AB90-743A279EC8F8}\\1053.mat\n"); Sleep(200); for (int i = 0; i < 10; i++) { Sleep(200); printf("*\n"); } for (int j = 0; j < 7; j++) { Sleep(100); printf("#:// Only with the mind can we see the essence of things. What is really important is invisible to\n"); } printf("*\n"); for (int j = 0; j < 5; j++) { Sleep(100); printf("#:// Only with the mind can we see the essence of things. What is really important is invisible to\n"); } for (int n = 15; n > 0; n--) { Sleep(100); for (int l = 0; l <= n; l++) { printf("0"); } printf("\n"); } Sleep(100); printf("*\n"); Sleep(100); printf("*\n"); Sleep(100); printf("*\n"); Sleep(100); printf("*\n"); Sleep(100); printf("0000000000000000000000000000000000\n"); Sleep(100); printf("………………\n"); Sleep(100); printf("Finish.\n"); Sleep(100); printf("Finish.\n"); for (int m = 0; m < 8; m++) { Sleep(100); printf("*\n"); } Sleep(100); printf("更新完成!\n"); Sleep(1000); printf("版本: LIFE V%d\n", year); Sleep(1000); printf("老赵,生日快乐,祝您生活愉快!\n"); Sleep(1000); } 

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 ? '*' : ' '); } //system("color 0c"); // 爱心更改为红色 putchar('\n'); } }

如果想要更改爱心颜色,在这个函数的末尾注释掉的system 这行代码,更改color 0c这个背景色代码,0 表示命令行背景颜色,c表示文字颜色,具体大家可以去CSDN上搜,有详细代码表示。

视频效果图 

C语言 生日代码

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/111532.html

(0)
上一篇 2026-01-24 11:21
下一篇 2026-01-24 11:33

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注微信