栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

用c语言爱心代码(可人机交互)

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

用c语言爱心代码(可人机交互)

 
#include
#include
#include
#include
#include  
void SetColor(unsigned short ForeColor,unsigned short BackGroundColor)
{
	HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(hCon,
				(ForeColor % 16) | (BackGroundColor % 16 * 16));
}

int main()
{
	float x, y;
	int s = 0, n, i, j;
	for (i = 1; i <= 50; i++)
	{
		SetColor(0, 14);
		printf(" ");
		printf("%d%%", 2 * i);
		Sleep(101 - 2 * i);
		printf("bbb");
	}
	SetColor(15, 0);
	printf("bn加载完成!即将进入:");
	Sleep(2000);
	system("cls");
	do
	{
		system("color 0E");
		for (i = 0; i <= 56; i++)
		{
			if (i >= 20)
			{
				printf("*");
				Sleep(10);
			} else
				printf(" ");
		}
		printf("n");
		for (i = 0; i <= 56; i++)
		{
			if (i >= 20)
			{
				printf("*");
				Sleep(10);
			} else
				printf(" ");
		}
		printf("nttt你想要怎样的心形:n");
		printf("nttt1:由love组成的心形!n");
		printf("nttt2:由随机字符组成的心形!n");
		printf("nttt3:由随机数字组成的心形!n");
		printf("nttt4:由随机颜色组成的心形!n");
		printf("nttt5:退出!n");
		for (i = 0; i <= 56; i++)
		{
			if (i >= 20)
			{
				printf("*");
				Sleep(10);
			} else
				printf(" ");
		}
		printf("n");
		for (i = 0; i <= 56; i++)
		{
			if (i >= 20)
			{
				printf("*");
				Sleep(10);
			} else
				printf(" ");
		}
		printf("nttt");
		srand(time(NULL));
		scanf("%d", &n);
		system("cls");
		switch (n)
		{
		case 1:
			for (x = 1.3; x >= -1.1; x -= 0.1)
			{
				for (y = -2; y <= 1.4; y += 0.053)
				{
					if (pow(x * x + y * y - 1, 3) -
					    x * x * x * y * y <= 0)
					{
						s++;
						if (s % 4 == 1)
							printf("l");
						if (s % 4 == 2)
							printf("o");
						if (s % 4 == 3)
							printf("v");
						if (s % 4 == 0)
							printf("e");
						Sleep(2);
					} else
						printf(" ");
				}
				printf("n");
			}
			printf("绘制完成,按任意键返回主页面!");
			break;
		case 2:
			for (x = 1.3; x >= -1.1; x -= 0.1)
			{
				for (y = -2; y <= 1.4; y += 0.053)
				{
					if (pow(x * x + y * y - 1, 3) -
					    x * x * x * y * y <= 0)
					{
						printf("%c",
						       rand() % 10 +
						       rand() % 10 + 97);
						Sleep(2);
					} else
						printf(" ");
				}
				printf("n");
			}
			printf("绘制完成,按任意键返回主页面!");
			break;
		case 3:
			for (x = 1.3; x >= -1.1; x -= 0.1)
			{
				for (y = -2; y <= 1.4; y += 0.053)
				{
					if (pow(x * x + y * y - 1, 3) -
					    x * x * x * y * y <= 0)
					{
						printf("%d", rand() % 10);
						Sleep(2);
					} else
						printf(" ");
				}
				printf("n");
			}
			printf("绘制完成,按任意键返回主页面!");
			break;
		case 4:
			for (x = 1.3; x >= -1.1; x -= 0.1)
			{
				for (y = -2; y <= 1.4; y += 0.053)
				{
					if (pow(x * x + y * y - 1, 3) -
					    x * x * x * y * y <= 0)
					{
						SetColor(0, rand() % 6 + 10);
						printf(" ");
						Sleep(2);
					} else
					{
						SetColor(0, 0);
						printf(" ");
					}
				}
				printf("n");
			}
			SetColor(15, 0);
			printf("绘制完成,按任意键返回主页面!");
			break;
		default:
			break;
		}
		getch();
		system("cls");
	}
	while (n != 5);
}




`#include
#include
#include
#include
#include  
void SetColor(unsigned short ForeColor,unsigned short BackGroundColor)
{
	HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(hCon,
				(ForeColor % 16) | (BackGroundColor % 16 * 16));
}

int main()
{
	float x, y;
	int s = 0, n, i, j;
	for (i = 1; i <= 50; i++)
	{
		SetColor(0, 14);
		printf(" ");
		printf("%d%%", 2 * i);
		Sleep(101 - 2 * i);
		printf("bbb");
	}
	SetColor(15, 0);
	printf("bn加载完成!即将进入:");
	Sleep(2000);
	system("cls");
	do
	{
		system("color 0E");
		for (i = 0; i <= 56; i++)
		{
			if (i >= 20)
			{
				printf("*");
				Sleep(10);
			} else
				printf(" ");
		}
		printf("n");
		for (i = 0; i <= 56; i++)
		{
			if (i >= 20)
			{
				printf("*");
				Sleep(10);
			} else
				printf(" ");
		}
		printf("nttt你想要怎样的心形:n");
		printf("nttt1:由love组成的心形!n");
		printf("nttt2:由随机字符组成的心形!n");
		printf("nttt3:由随机数字组成的心形!n");
		printf("nttt4:由随机颜色组成的心形!n");
		printf("nttt5:退出!n");
		for (i = 0; i <= 56; i++)
		{
			if (i >= 20)
			{
				printf("*");
				Sleep(10);
			} else
				printf(" ");
		}
		printf("n");
		for (i = 0; i <= 56; i++)
		{
			if (i >= 20)
			{
				printf("*");
				Sleep(10);
			} else
				printf(" ");
		}
		printf("nttt");
		srand(time(NULL));
		scanf("%d", &n);
		system("cls");
		switch (n)
		{
		case 1:
			for (x = 1.3; x >= -1.1; x -= 0.1)
			{
				for (y = -2; y <= 1.4; y += 0.053)
				{
					if (pow(x * x + y * y - 1, 3) -
					    x * x * x * y * y <= 0)
					{
						s++;
						if (s % 4 == 1)
							printf("l");
						if (s % 4 == 2)
							printf("o");
						if (s % 4 == 3)
							printf("v");
						if (s % 4 == 0)
							printf("e");
						Sleep(2);
					} else
						printf(" ");
				}
				printf("n");
			}
			printf("绘制完成,按任意键返回主页面!");
			break;
		case 2:
			for (x = 1.3; x >= -1.1; x -= 0.1)
			{
				for (y = -2; y <= 1.4; y += 0.053)
				{
					if (pow(x * x + y * y - 1, 3) -
					    x * x * x * y * y <= 0)
					{
						printf("%c",
						       rand() % 10 +
						       rand() % 10 + 97);
						Sleep(2);
					} else
						printf(" ");
				}
				printf("n");
			}
			printf("绘制完成,按任意键返回主页面!");
			break;
		case 3:
			for (x = 1.3; x >= -1.1; x -= 0.1)
			{
				for (y = -2; y <= 1.4; y += 0.053)
				{
					if (pow(x * x + y * y - 1, 3) -
					    x * x * x * y * y <= 0)
					{
						printf("%d", rand() % 10);
						Sleep(2);
					} else
						printf(" ");
				}
				printf("n");
			}
			printf("绘制完成,按任意键返回主页面!");
			break;
		case 4:
			for (x = 1.3; x >= -1.1; x -= 0.1)
			{
				for (y = -2; y <= 1.4; y += 0.053)
				{
					if (pow(x * x + y * y - 1, 3) -
					    x * x * x * y * y <= 0)
					{
						SetColor(0, rand() % 6 + 10);
						printf(" ");
						Sleep(2);
					} else
					{
						SetColor(0, 0);
						printf(" ");
					}
				}
				printf("n");
			}
			SetColor(15, 0);
			printf("绘制完成,按任意键返回主页面!");
			break;
		default:
			break;
		}
		getch();
		system("cls");
	}
	while (n != 5);
}





#include
#include
int main(){
float y, x, z;
printf("nnttt那一天n");
printf("tt 第一次遇见你n");
printf("ttt忘不了n");
printf("tt 你的容颜n");
printf("tt若轻云之蔽月,如流风之回雪n");
printf("nn");
printf("ttt其实n");
printf("tt 有一句话n");
printf("tt 我一直想对你说:n");
for (y = 2.5; y >= -1.6; y = y - 0.2)
{
    for (x = -3; x <= 4.8; x = x + 0.1)
    {
          (pow((x * x + y * y - 1), 3) <= 3.6 * x * x * y * y * y|| (x > -2.4 && x < -2.1 && y < 1.5 && y > -1)|| (((x < 2.5 && x > 2.2) || (x > 3.4 && x < 3.7)) && y > -1 && y < 1.5) || (y > -1 && y < -0.6&& x < 3.7&& x >2.2)) ? printf("*") :printf(" “);
       }
          printf(”n");
}
          getchar();
}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/588154.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号