使用c++实现输出爱心(软件:visual Studio)

cs 复制代码
#include <iostream>
using namespace std;

int main()
{
    //爱心曲线方程(x^2+y^2-a)^3-x^2*y3=0
    double a = 0.5;
    //定义绘图边界
    double bound = 1.3 * sqrt(a);
    //x,y坐标变化步长
    double step = 0.05;

    //二维扫描所有点,外层逐层扫描
    for (double y = bound; y >= -bound; y -= step)
    {
        //内层逐点扫描
        for (double x = -bound; x <= bound; x += 0.5 * step)
        {
            double result = pow( (pow(x, 2) + pow(y, 2)-a), 3) - pow(x, 2) * pow(y, 3);
            if (result <= 0)
                cout << "*";
            else
                cout << " ";
        }
        cout << endl;
    }
    cin.get();

    return 0;
}
相关推荐
meiying883811 小时前
快递单号批量查询Python脚本:从手动到自动化的完整实现
开发语言·python·自动化
@大迁世界11 小时前
告别 Go,拥抱 Rust
开发语言·golang·rust
SEO_juper11 小时前
Node.js 重定向链检测工具:301 跳了几跳、有没有成环,一次看清
xml·开发语言·python·node.js·json·bash
学逆向的11 小时前
C 指针常量与常量指针
c语言·开发语言·网络安全
小郎君65812 小时前
Vue keep-alive 切标签后滚动位置回顶?因为 onDeactivated 里读到的 scrollTop 是 0
算法
低调滴开发12 小时前
3 行代码写崩一个函数?切片才是 Rust 字符串处理的正确姿势
开发语言·后端·rust
CodeYp201912 小时前
第15讲:二叉搜索树
开发语言·c++·二叉搜索树
邵奈一12 小时前
GPT-6.1 Terra速度是Sol的3倍,价格减半
算法
RaaS10012 小时前
Node.js Brotli RCE 漏洞自查指南:fetch、undici、axios 都在影响面,三分钟确认你的版本
人工智能·深度学习·算法
猫猫.15312 小时前
HashTable、HashMap、ConcurrentHashMap 核心区别总结
java·开发语言·java-ee