5.20装杯爱心❤

        马上5.20到了,没啥好送给大家的,就祝天下有情人终成眷属,大家拿去这段代码给自己的心上人看吧!

#include<stdio.h>
#include<windows.h>
#include<math.h>
#include<time.h>
#include<stdlib.h>
void ProBar()
{
	char bar[101] = { 0 };
	char ch[] = { "|/-\\" };
	int i = 0;
	int y = 0;
	while (i <= 100)
	{    
		y = rand() % 8 + 40;
		int x = rand() % 8 + 30;
		printf("[\033[1;%d;%dm%-100s\033[0m][\033[1;%d;%dm%2d\033[0m%%][%c]\r", x, 40, bar, y - 10, 40, i, ch[i % 4]); //控制颜色 
		fflush(stdout);
		Sleep(100);
		if (i < 100)
		{
			bar[i] = '=';
		}
		i++;
		if (i < 100)
			bar[i] = '>';
	}
	printf("\n");
}

double func(float x, float y)
{
	float a = (x * x + y * y - 1) * (x * x + y * y - 1) * (x * x + y * y - 1);
	return a - x * x * y * y * y;
}

void Love()
{
	float x = 0.0f;
	float y = 0.0f;
	char key = '*';
	for (y = 1.5f; y >= -1.0f; y -= 0.1f)
	{
		key = '*';
		for (x = -1.5f; x < 1.5f; x += 0.05f)
		{
			if (func(x, y) <= 0.0)
			{
				int x = rand() % 8 + 30;
				printf("\033[1;%d;40m%c\033[0m", x, key);
			}
			else
			{
				printf(" ");
			}
		}
		fflush(stdout);
		Sleep(1000);//控制每一行爱心出现的时间间隔
		printf("\n");
	}
	
	printf("\t\t\t I LOVE YOU!\n");
}
int main()
{
	srand((unsigned int)time(NULL));
	ProBar();
	Love();
	return 0;
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值