用c++打印一个心形的图案:

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    float x, y;
    for (y = 1.5f; y >-1.5f; y -= 0.1f)
    {
        for (x = -1.5f; x <1.5f; x += 0.05f)
        {
            float a = x*x + y*y - 1;
            if ((a*a*a- x*x*y*y*y)<=0)//心形方程
                cout << '*';
            else cout << " ";
        }
        cout << endl;
    }
    return 0;
}

效果图如下:

这里写图片描述


版权声明:本文为lxh_gdmu原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/lxh_gdmu/article/details/47764483