#include<stdio.h>
void other() //绘制爱心
{
printf("请输入爱心的大小(4-100):\n");
int size;
scanf("%d", &size);
int max = (size - 3) * 8 + 2*size+3;
int hang = 0;
for (int i = size - 2; i > 0; i--) { //行
hang++;
for (int j = 1; j <= 2 * i - 1; j++)printf(" ");
for (int k = 1; k <= size + 4 * (hang - 1); k++)printf("*");
for (int l = 1; l <= 2 * i - 1; l++)printf(" ");
for (int j = 1; j <= 2 * i - 1; j++)printf(" ");
for (int k = 1; k <= size + 4 * (hang - 1); k++)printf("*");
for (int l = 1; l <= 2 * i - 1; l++)printf(" ");
printf("\n");
}
for (int yy = 1; yy <= size -2; yy++) {
for (int kk = 1; kk <= max; kk++)printf("*");
printf("\n");
}//大三角
for (int i = 1; i <= ((max - 3) / 4) + 1; i++) {//行
for (int j = 1; j <= 1 + 2 * (i - 1); j++)printf(" ");
for (int k = 1; k <= (max - 2*(1 + 2 * (i - 1))); k++)printf("*");
printf("\n");
}
}
int main()
{
other();
return 0;
}
搞不明白这个爱心会很难吗,网上好多求源码的,静下心就能找出规律(虽然我这个爱心还有所欠缺)