、大家好。
我还四
那过三好鞋生
呸
三好学生
520又到了
大家有woman friend and man friend(作者的英语有点飘)了吗?
没有的扣1
投的扣2
反正我是single body dog(单身狗)
为了脱离single body(单身)
作者扛着被老妈揍的风险
写了个表白神器(为了水文章也是拼了)
请把文章看到最后
否则后果自负
花不多说,上代码:
#include <iostream>
#include <ctime>
#include <cmath>
#include <windows.h>
#include <conio.h>
#define WB "color 70"
#define WR "color 7C"
#define unit "* "
#define ESC 27
#define posHeartX 50
#define posHeartY 5
enum
{
row = 46,
col = 47
};
bool Heart[row * col];
void init(void);
void goto_xy(int x, int y);
void illuminate(void);
void show(void);
int main(void)
{
using std::cin;
using std::cout;
int key = 0;
system(WB);
init();
illuminate();
cin.get();
system(WR);
while ((key = getch()) && (key != ESC))
{
system("cls");
show();
}
cout << "\nPress any key to continue.\n";
cin.get();
return 0;
}
void init(void)
{
for (int i = 0; i < row; i++)
for (int j = 0; j < col; j++)
Heart[i * col + j] = false;
}
void goto_xy(int x, int y)
{
HANDLE hOut;
hOut = GetStdHandle(STD_OUTPUT_HANDLE);
COORD pos = {x, y};
SetConsoleCursorPosition(hOut, pos);
}
void illuminate(void)
{
using std::cout;
double x, y, leftValue, rightValue;
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++)
{
x = -1.15 + 0.05 * j;
y = +1.25 - 0.05 * i;
leftValue = x * x * y * y * y;
rightValue = pow(x * x + y * y - 1, 3);
if (leftValue >= rightValue)
{
Heart[i * col + j] = true;
goto_xy(0, 0);
cout << "v positive " << leftValue << " >= " << rightValue;
goto_xy(posHeartX + 2 * j, posHeartY + i);
cout << "|";
}
else
{
Heart[i * col + j] = false;
goto_xy(0, 0);
cout << "x negative " << leftValue << " < " << rightValue;
goto_xy(posHeartX + 2 * j, posHeartY + i);
cout << "O";
}
Sleep(7);
}
}
}
void show(void)
{
using std::cout;
int fromWhere;
int x, y;
srand((unsigned int)clock());
do
{
fromWhere = rand() % (row * col);
} while (Heart[fromWhere] == false);
x = fromWhere / col;
y = fromWhere % col;
int Rx, Ry, Rmax;
Rx = x > (row - 1 - x) ? x : (row - 1 - x);
Ry = y > (col - 1 - y) ? y : (col - 1 - y);
Rmax = (int)sqrt(Rx * Rx + Ry * Ry) + 1;
for (int r = 1; r < Rmax; r++)
{
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++)
{
if ((((i - x) * (i - x) + (j - y) * (j - y)) < r * r) && Heart[i * col + j])
{
goto_xy(posHeartX + 2 * j, posHeartY + i);
cout << unit;
}
}
}
Sleep(20);
}
}
运行的结果自己摸索
杠精:作者可真懒,注释都没写。
对于这种键盘侠我只能说
自己体会下被衣架打的体验
毕竟也不能影响学习
(作者的英语就是被Java,Python,C++,html,C#,PHP,易语言,VBScript,js,CSS影响的)
算了不吹牛了
只有Python,C++,html
还有作者不建议大家直接运行exe
在cpp文件里运行比较好
因为如果运行exe你没反应过来打开全屏他就已经打印很多了
这样子你将得到一个不完整的爱心
在cpp文件运行的话
它编译的比较慢(作者只知道DevC++,其它的不知道)
好了以上都是本期内容
谢谢观看
看到这里不妨点赞加关注和收藏
成为我的粉丝拥有专属福利哦
比如明日之后完整版
如果不是的话只能看到零零碎碎的代码
点个关注也行
因为作者比较穷
有些设了VIP才能看
谢谢大家