/*爱心代码:*/
#include
#include
#include
#include
#define U 0.1
#define V 0.053
void SetColor(unsigned short ForeColor,unsigned short BackGroundColor)
{
HANDLE hCon=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hCon,(ForeColor%16)|(BackGroundColor%16*16));
}
int main()
{
int i,s=0,t,a=10,b=11,c=12,d=13,e=14;
int z[] = {32,32,206,210,176,174,209,197,209,197,33,32,32};
/*
用两位ASCⅡ码表示汉字,中间用“,”分隔;
32,32–表示空格
206,210–我
176,174–爱
209,197–雅

(想找ASCⅡ码对应的汉字,可以下载“中英文字符编码查询”小软件,可以点击我的头像到我发布的资源中查找)
*/

float x,y;
srand(time(NULL));
for(y=1.3;y>=-1.1;y-=U)
{
for(x=-2;x<1.4;x+=V)
{
if((((x*x+y*y-1)*(x*x+y*y-1)*(x*x+y*y-1)-x*x*y*y*y)<=0))
{
if(y>=1.3-10*U||y<=1.3-11*U)
{
s++;
if(s%4==1){SetColor(a,0);printf(“l”);}
if(s%4==2){SetColor(e,0);printf(“o”);}
if(s%4==3){SetColor(c,0);printf(“v”);}
if(s%4==0){SetColor(d,0);printf(“e”);}
}
else
{
for(i = 0;i < 42;i++)
{
if(i=28)
{
s++;
if(s%4==1){SetColor(a,0);printf(“l”);}
if(s%4==2){SetColor(e,0);printf(“o”);}
if(s%4==3){SetColor(c,0);printf(“v”);}
if(s%4==0){SetColor(d,0);printf(“e”);}
}
else
{
SetColor(b,0);
printf(“%c”, z[i-15]);
Sleep(50);
}
}
break;
}
}
else
printf(” “);
Sleep(1);
}
printf(“\n”);
}
printf(“l love you”);
getchar();
while(1)
{
system(“cls”);
t=a;a=b;b=c;c=d;d=e;e=t;
for(y=1.3;y>=-1.1;y-=U)
{
for(x=-2;x<1.4;x+=V)
{
if((((x*x+y*y-1)*(x*x+y*y-1)*(x*x+y*y-1)-x*x*y*y*y)<=0))
{
if(y>=1.3-10*U||y<=1.3-11*U)
{
s++;
if(s%4==1){SetColor(a,0);printf(“l”);}
if(s%4==2){SetColor(b,0);printf(“o”);}
if(s%4==3){SetColor(c,0);printf(“v”);}
if(s%4==0){SetColor(d,0);printf(“e”);}
}
else
{
for(i = 0;i < 42;i++)
{
if(i=28)
{
s++;
if(s%4==1){SetColor(a,0);printf(“l”);}
if(s%4==2){SetColor(b,0);printf(“o”);}
if(s%4==3){SetColor(c,0);printf(“v”);}
if(s%4==0){SetColor(d,0);printf(“e”);}
}
else
{
SetColor(e,0);
printf(“%c”, z[i-15]);
}
}
break;
}
}
else
printf(” “);
}
printf(“\n”);
}
Sleep(1000);
system(“cls”);

}
}

效果图:

按过回车之后,会动态表变换颜色

中英文字符编码查询—可以到我的资源中查找哦

关注博客,还有更多表白技巧哦。