c语言画心形的代码(c语言画心形的代码怎么写)

http://www.itjxue.com  2023-03-06 02:03  来源:未知  点击次数: 

如何用C语言画一个“心形”

给你一个我早先写的供参考——

#include?stdio.h

#include?"string.h"

int?main(void){

char?a[]="I?love?you?I?love?you?I?love?you?I?l";

printf("\n\n\n");

printf("%*.*s\n",58,21,"_*=_???????????_=*_");

printf("%*.*s\n",61,25,"I?love?yo???????u?I?love!");

printf("%*.*s\n",63,29,"I?love?you?I?l?ove?you?I?love");

printf("%*.*s\n",65,33,a);

printf("%*.*s\n",66,35,a);

printf("%*.*s\n",66,35,a);

printf("%*.*s\n",65,33,a);

printf("%*.*s\n",64,31,a);

printf("%*.*s\n",63,29,a);

printf("%*.*s\n",61,25,a);

printf("%*.*s\n",59,21,a);

printf("%*.*s\n",57,17,a);

printf("%*.*s\n",55,13,a);

printf("%*.*s\n",53,9,a);

printf("%*.*s\n",51,5,a);

printf("%*.*s\n",50,3,a);

printf("%*.*s\n",49,1,a);

return?0;

}

c语言 心形图案代码

#include?stdio.h

int?main()?{

????for?(float?y?=?1.5f;?y??-1.5f;?y?-=?0.1f)?{

????????for?(float?x?=?-1.5f;?x??1.5f;?x?+=?0.05f)?{

????????????float?a?=?x?*?x?+?y?*?y?-?1;

????????????putchar(a?*?a?*?a?-?x?*?x?*?y?*?y?*?y?=?0.0f???'*'?:?'?');

????????}

????????putchar('\n');

????}

}

c语言如何画出心形,谢谢 一位大神说我没有定义变量,还是有错误

修改两个地方....看下面代码注释

#include?stdio.h

int?main()

{

float?x;

float?y;???//这里是一处?...原因是原来在循环里声明变量是C99标准里新的特性。。编译器默认不支持

for(y=1.5f;?y-1.5f;?y-=0.1f){

for?(?x=-1.5f;?x1.5f;x+=0.05f){

float?z=x*x+y*y-1;

float?f=z*z*z-x*x*y*y;

putchar(f?=?0.0f???".:-=+*#%@"[(int)(f?*?-8.0f)]?:?'?');

}

putchar('\n');??//另一处...原来拼写错误...

}

}

(责任编辑:IT教学网)

更多

推荐新手入门文章