爱心代码分享

170 阅读1分钟

如图所示:

**注意标点中英区别

image.png

编译运行得到如下结果:

image.png

代码如下:

#include <stdio.h>
#include<Windows.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	system("color 0c");
	
	float x,y,a;
	for(y=1.4f;y>-1.4f;y-=0.1f){
		for(x=-1.4f;x<1.4f;x+=0.05f){
			a=x*x+y*y-1;
			putchar((a*a*a-x*x*y*y*y<0.0f)?'x':' ');
		}
		printf("\n");
		Sleep(100);	
	}
	printf("\t天天开心!!!\n");
}

复制到c++就可以编译运行,得到爱心。 祝你天天开心!!!