![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/a5db4046c13bbdf244a166b6d3c143db.jpeg#pic_center)
此图静态的黑白爱心图,主要靠数学计算,运用for循环即可!!!
1、具体程序
#include<stdio.h>
int main() {
int i, j, k, l, m;
char c = '*';
//开头空5行
for (i = 1; i <= 5; i++)
printf("\n");
//打印前三行
for (i = 1; i <= 3; i++) {//前3行中间有空隙分开写
for (j = 1; j <= 32 - 2 * i; j++)//左边的空格,每下一行比上一行少2
printf(" ");
for (k = 1; k <= 4 * i + 1; k++)
printf("%c", c);
for (l = 1; l <= 13 - 4 * i; l++)//中间空格,每下一行比上一行少4
printf(" ");
for (m = 1; m <= 4 * i + 1; m++)
printf("%c", c);
printf("\n");
}
for (i = 1; i <= 3; i++) {
for (j = 1; j <= 25; j++)
printf(" ");
for (k = 1; k <= 29; k++)
printf("%c", c);
printf("\n");
}
//打印下面七行的字符
for (i = 7; i >= 1; i--) {
for (j = 1; j <= 40 - 2 * i; j++)
printf(" ");
for (k = 1; k <= 4 * i - 1; k++)
printf("%c", c);
printf("\n");
}
//打印最后一行的字符
for (i = 1; i <= 39; i++)
printf(" ");
printf("%c", c);
printf("\n\n");
//打印最后一行的字
for (i = 1; i <= 24; i++)
printf(" ");
puts("岁月不曾辜负,我又怎敢辜负岁月!");
for (i = 1; i <= 5; i++)//最后空出5行
printf("\n");
return 0;
}
2、执行结果
本程序只供参考使用,喜欢的欢迎收藏……