鱼C论坛

 找回密码
 立即注册
查看: 2833|回复: 2

[技术交流] 2018献给母亲的礼物

[复制链接]
发表于 2018-5-13 13:51:57 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 Sj中国智造 于 2018-5-13 13:54 编辑
  1. #include <windows.h>
  2. #include <iostream>
  3. #include <cstdio>
  4. #include <cstdlib>
  5. #include <cmath>
  6. #include <string>
  7. #include <tchar.h>

  8. #pragma comment(lib,"Winmm.lib")//播放音乐的
  9. using namespace std;

  10. float f(float x, float y, float z) {
  11.         float a = x * x + 9.0f / 4.0f * y * y + z * z - 1;
  12.         return a * a * a - x * x * z * z * z - 9.0f / 80.0f * y * y * z * z * z;
  13. }

  14. float h(float x, float z) {
  15.         for (float y = 1.0f; y >= 0.0f; y -= 0.001f)
  16.                 if (f(x, y, z) <= 0.0f)
  17.                         return y;
  18.         return 0.0f;
  19. }

  20. int main()
  21. {
  22.         system("mode con cols=120 lines=40");
  23.         HANDLE fd = GetStdHandle(STD_OUTPUT_HANDLE);
  24.         CONSOLE_CURSOR_INFO cinfo;
  25.         cinfo.bVisible = 0;
  26.         cinfo.dwSize = 1;
  27.         SetConsoleCursorInfo(fd, &cinfo);

  28.         MessageBox(NULL, TEXT("开始前,请把电脑的声音开大!"), TEXT("即将开始...."), MB_ICONINFORMATION);

  29.         MessageBox(NULL, TEXT("今天是2018年5月13日,妈妈,母亲节快乐!"), TEXT("开始"), MB_OK);

  30.         mciSendString(TEXT("open "./muqin.mp3" alias mymusic"), NULL, 0, NULL);
  31.         mciSendString(TEXT("play mymusic"), NULL, 0, NULL);


  32.         SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0x0C);
  33.         HANDLE o = GetStdHandle(STD_OUTPUT_HANDLE);
  34.         _TCHAR buffer[25][80] = { _T(' ') };
  35.         _TCHAR ramp[] = _T(".:-=+*#%@");
  36.         int count = 0;
  37.         int count1 = 0;

  38.         double second = 270;
  39.         int minute = int (second/60);
  40.         for (float t = 0.0f;minute!=0; t += 0.1f) {
  41.                 int sy = 0;
  42.                 float s = sinf(t);//返回一个sin的浮点数
  43.                 float a = s * s * s * s * 0.2f;

  44.                 for (float z = 1.3f; z > -1.2f; z -= 0.1f) {
  45.                         _TCHAR* p = &buffer[sy++][0];
  46.                         float tz = z * (1.2f - a);
  47.                         for (float x = -1.5f; x < 1.5f; x += 0.05f) {
  48.                                 float tx = x * (1.2f + a);
  49.                                 float v = f(tx, 0.0f, tz);
  50.                                 if (v <= 0.0f) {
  51.                                         float y0 = h(tx, tz);
  52.                                         float ny = 0.01f;
  53.                                         float nx = h(tx + ny, tz) - y0;
  54.                                         float nz = h(tx, tz + ny) - y0;
  55.                                         float nd = 1.0f / sqrtf(nx * nx + ny * ny + nz * nz);
  56.                                         float d = (nx + ny - nz) * nd * 0.5f + 0.5f;
  57.                                         *p++ = ramp[(int)(d * 5.0f)];
  58.                                 }
  59.                                 else
  60.                                         *p++ = ' ';
  61.                         }
  62.                 }

  63.                 for (sy = 0; sy < 25; sy++) {
  64.                         COORD coord = { 0, sy };
  65.                         SetConsoleCursorPosition(o, coord);
  66.                         WriteConsole(o, buffer[sy], 79, NULL, 0);
  67.                 }

  68.                 Sleep(66);
  69.                 second = second - 100.0 / 1000;
  70.                 minute =int(second / 60);
  71.                 cout << "祝老妈2018年母亲节快乐!" << endl;
  72.                 cout << "\t\t\t\t\t\t\t\t\t\t\t致我最最爱的妈妈!-------儿子" << endl<<endl<<endl;
  73.                 printf("\t\t\t\t\t\t\t\t\t\t还剩%d分钟哦!请耐心等待,末尾有彩蛋!\n",minute);
  74.         }

  75.         system("cls");//清屏

  76.         for (int i = 0; i < 10; i++)
  77.         {
  78.                 COORD coord = { 50,10 };
  79.                 SetConsoleCursorPosition(o, coord);
  80.                 printf("%d秒后,惊喜即将出现!\n", 10-i);
  81.                 Sleep(1000);
  82.         }

  83.         COORD coord = { 0,0 };
  84.         SetConsoleCursorPosition(o, coord);


  85.         for (int i = 0; i < 10; i++)
  86.         {
  87.                 cout << "ooooooooooooooooooooo\t\t\t\t\t\t\tooooo\t\t\tooooo" << endl;
  88.                 cout << "ooooooooooooooooooooo\t\t\t\t\t\t\tooooo\t\t\tooooo" << endl;
  89.                 cout << "ooooooooooooooooooooo\t\t\t\t\t\t\tooooo\t\t\tooooo" << endl;
  90.                 cout << "      oooooo                                                            ooooo                   ooooo" << endl;
  91.                 cout << "      oooooo                                                            ooooo                   ooooo" << endl;
  92.                 cout << "      oooooo                                                            ooooo                   ooooo" << endl;
  93.                 cout << "      oooooo                                                            ooooo                   ooooo" << endl;
  94.                 cout << "      oooooo                                                            ooooo                   ooooo" << endl;
  95.                 cout << "      oooooo                                                            ooooo                   ooooo" << endl;
  96.                 cout << "      oooooo                                                            ooooo                   ooooo" << endl;
  97.                 cout << "      oooooo                                                            ooooo                   ooooo" << endl;
  98.                 cout << "      oooooo                                                            ooooo                   ooooo" << endl;
  99.                 cout << "      oooooo                                                            ooooo                   ooooo" << endl;
  100.                 cout << "      oooooo                                                            ooooo                   ooooo" << endl;
  101.                 cout << "      oooooo                                                            ooooo                   ooooo" << endl;
  102.                 cout << "      oooooo                                                            ooooo                   ooooo" << endl;
  103.                 cout << "      oooooo                                                            ooooo                   ooooo" << endl;
  104.                 cout << "      oooooo                                                            ooooo                   ooooo" << endl;
  105.                 cout << "      oooooo                                                            ooooo                   ooooo" << endl;
  106.                 cout << "      oooooo                                                            ooooo                   ooooo" << endl;
  107.                 cout << "      oooooo                                                            ooooo                   ooooo" << endl;
  108.                 cout << "      oooooo                                                            ooooo                   ooooo" << endl;
  109.                 cout << "      oooooo                                                            ooooo                   ooooo" << endl;
  110.                 cout << "ooooooooooooooooooooo                                      \t\t oooo                   oooo  " << endl;
  111.                 cout << "ooooooooooooooooooooo                                      \t\t  ooo                   ooo  " << endl;
  112.                 cout << "ooooooooooooooooooooo                                         \t\t     ooooooooooooooooooo  " << endl;
  113.                
  114.                 Sleep(1000);
  115.                 coord.X = 0;
  116.                 coord.Y = 0;
  117.                 SetConsoleCursorPosition(o, coord);
  118.                 for (float y = 1.5f; y > -1.5f; y -= 0.1f) {

  119.                         for (float x = -1.5f; x < 1.5f; x += 0.05f) {

  120.                                 float a = x * x + y * y - 1;

  121.                                 putchar(a * a * a - x * x * y * y * y <= 0.0f ? '*' : ' ');

  122.                         }
  123.                         putchar('\n');
  124.                         Sleep(33);
  125.                 }
  126.                 Sleep(1000);
  127.                 system("cls");
  128.                 if (i == 3)
  129.                 {
  130.                         mciSendString(TEXT("stop mymusic"), NULL, 0, NULL);
  131.                         system(".\\2.mp4");
  132.                 }
  133.         }

  134.         return 0;
  135. }
复制代码


源码上传,资源文件请通过百度云下载,在win7和win10上运行正常!祝全天下母亲母亲节快乐!!
链接: https://pan.baidu.com/s/1t8HoTq3DWJks6CIkJAkOEQ 密码: f2gp
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2018-5-13 14:41:50 | 显示全部楼层
新手问下需要用Visual studio运行吗,还有别的方法没
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-5-13 14:50:02 | 显示全部楼层
本帖最后由 Sj中国智造 于 2018-5-13 15:18 编辑
likesunshine 发表于 2018-5-13 14:41
新手问下需要用Visual studio运行吗,还有别的方法没


windows这个库本来就是微软的,其他的支持不是很好,你可以装vc2010学习版,很小,而且其实我也是新手,我很早就开始用vs2017,不得不说vs2017的确很强大,只需三分钟,你就会爱上这款软件
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-3-29 16:02

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表