C++---代码情诗(动画版)

代码

#include <iostream>
#include <ctime>
#include <windows.h>
#define BEGIN_X 22
#define BEGIN_Y 0
#define UPSIDEMAX 88

#define DOWNSIDEMAX UPSIDEMAX-2
#define LEFTSIDEMAX 20
#define RIGHTSIDEMAX LEFTSIDEMAX
#define UPSIDE_X BEGIN_X+2
#define UPSIDE_Y BEGIN_Y
#define LEFTSIDE_X BEGIN_X
#define LEFTSIDE_Y UPSIDE_Y+1
#define RIGHTSIDE_X BEGIN_X+UPSIDEMAX
#define RIGHTSIDE_Y BEGIN_Y+1
#define DOWNSIDE_X BEGIN_X+2
#define DOWNSIDE_Y LEFTSIDEMAX+BEGIN_Y
using namespace std;
void main()
{
void frame();
void gotoXY(int, int);

clock_t start;
int i = BEGIN_Y, n = 0, k = 0;
frame();
start = clock ();



while (i++ < DOWNSIDE_Y - 1 - n && k < RIGHTSIDE_X - (BEGIN_X + 5))
{
gotoXY(BEGIN_X + 5 + k, i);
if(((  (27<=(27 + k))&&  ((27+ k))<=39 )&&(i==2||i==19))||(((27+ k)==33))&&((i<=18)&&(i>=2))||( ((i-10)==(66-(27+k))/3)&&((i>=6)&&(i<=10))  )|| (((i-10)==((27+k)-66)/3)&&((i>=6)&&(i<=10)) )||( (((k+27)==81||(k+27)==51)&&(i==7))||(((k+27)==84||(k+27)==48)&&(i==8)) || (((k+27)==87||(k+27)==45)&&(i==9)) || ( ((i-9)==(87-(27+k))/3)&&((i>=9)&&(i<=16))  )|| ( ((i-9)==((27+k)-45)/3)&&((i>=9)&&(i<=16))  )||  (((27+ k)>=93)&&((27+ k)<=108))&&(i==15) ) ||  ( ((i<=15)&&(i>=5))&&(((k+27)==93)||((k+27)==108))     )            )
//cout<<"*";
cout << "■";
cout<<"*"<<endl;
while (clock () - start < 0.0000025 * CLOCKS_PER_SEC)
;
gotoXY(BEGIN_X + 5 + k, i);
//start = clock ();
if (i != DOWNSIDE_Y - 1 - n)
cout << " ";
start = clock ();
frame();
if (i == DOWNSIDE_Y - 1 - n)
i = BEGIN_Y, n++;
if (n == LEFTSIDEMAX - 1)
i = BEGIN_Y, n = 0, k += 3;
}
cout << "Bye!" << endl;


//system("cls");



}





void frame()
{
void gotoXY(int, int);
gotoXY(BEGIN_X, BEGIN_Y);
cout << "┏";
gotoXY(UPSIDE_X, UPSIDE_Y);
for (int i = 0; i < UPSIDEMAX; i += 2)
{
cout << "┅";
gotoXY(UPSIDE_X + i, UPSIDE_Y);
}
cout << "┓";
gotoXY(LEFTSIDE_X, LEFTSIDE_Y);
for (i = 0; i < LEFTSIDEMAX; i++)
{
cout << "┇";
gotoXY(LEFTSIDE_X, LEFTSIDE_Y + i);
}
cout << "┗";
gotoXY(RIGHTSIDE_X, RIGHTSIDE_Y);
for (i = 0; i < RIGHTSIDEMAX; i++)
{
cout << "┇";
gotoXY(RIGHTSIDE_X, RIGHTSIDE_Y + i);
}
cout << "┛";
gotoXY(DOWNSIDE_X, DOWNSIDE_Y);
for (i = 0; i < DOWNSIDEMAX; i += 2)
{
gotoXY(DOWNSIDE_X + i, DOWNSIDE_Y);
cout << "┅";
}
putchar (10);
}




void gotoXY(int x, int y)
{
HANDLE hout;
COORD coord = {x, y};
hout = GetStdHandle (STD_OUTPUT_HANDLE);
SetConsoleCursorPosition (hout, coord);
}

程序运行界面

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

发布了155 篇原创文章 · 获赞 110 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/weixin_44225182/article/details/103625377