用c++写一段爱心代码 其中包含倪丹我爱你的字体 爱心跳动
时间: 2023-10-18 13:15:37 浏览: 158
以下是一段C++代码,实现了一个跳动的爱心,并且包含了“倪丹我爱你”的字体:
```c++
#include <iostream>
#include <Windows.h>
using namespace std;
void SetConsoleFont(int FontSize)
{
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_FONT_INFOEX font = { 0 };
font.cbSize = sizeof(font);
GetCurrentConsoleFontEx(hOut, FALSE, &font);
font.dwFontSize.Y = FontSize;
SetCurrentConsoleFontEx(hOut, FALSE, &font);
}
void gotoxy(int x, int y)
{
COORD pos = { x, y };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
int main()
{
SetConsoleFont(24); // 设置字体大小
system("color 0c"); // 设置背景颜色和字体颜色
while (true) {
gotoxy(40, 10);
cout << "倪丹我爱你" << endl;
gotoxy(40, 12);
cout << " ♥♥♥ " << endl;
gotoxy(40, 14);
cout << " ♥ " << endl;
gotoxy(40, 16);
cout << " ♥ " << endl;
gotoxy(40, 18);
cout << " ♥ " << endl;
gotoxy(40, 20);
cout << " ♥ " << endl;
gotoxy(40, 22);
cout << " ♥ " << endl;
Sleep(500);
gotoxy(40, 12);
cout << " ♥♥♥ " << endl;
gotoxy(40, 14);
cout << " ♥ " << endl;
gotoxy(40, 16);
cout << " ♥ " << endl;
gotoxy(40, 18);
cout << " ♥ " << endl;
gotoxy(40, 20);
cout << " ♥ " << endl;
gotoxy(40, 22);
cout << " ♥ " << endl;
Sleep(500);
}
return 0;
}
```
运行该程序后,即可看到一个跳动的爱心,并且屏幕上显示了“倪丹我爱你”这句话。
阅读全文