跳动的爱心C语言代码
时间: 2023-11-06 17:05:26 浏览: 248
好的,以下是跳动的爱心C语言代码:
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main()
{
int i, j, k;
double x, y, z, f1, f2;
char a[80][80] = {" "};
char b[] = "I Love You!";
for (i = 0; i <= 80; i++)
{
for (j = 0; j <= 80; j++)
{
x = (j - 40) * 0.05;
y = (i - 40) * 0.1;
z = sqrt(x * x + y * y);
if (z == 0)
{
f1 = 0;
f2 = 0;
}
else
{
f1 = sin(z) / z;
f2 = cos(z) / z;
}
k = (int)((f1 + 1) * 8); if (k == 16)
k = 15;
a[i][j] = "ILoveYou"[k];
}
}
for (i = 0; i <= strlen(b); i++)
{
for (j = 0; j <= 80; j++)
{
printf("%c", a[i][j]);
}
printf("\n");
}
return 0;
}
```
阅读全文