【C语言】用"I love you!"打印心形

#include<iostream>
#include<cmath>
using namespace std;
int main()
{

    float x, y;
    string s = "I love you!";
    int l = s.length();
    for (y = 1.3f; y >= -1.1f; y -= 0.06f)
    {
        int t = 0;
        for (x = -1.1f; x <= 1.1f; x += 0.025f)
        {
            double heart = x * x + (5.0 * y / 4.0 - sqrt(abs(x))) * (5.0 * y / 4.0 - sqrt(abs(x)));
            if (heart <= 1) {
                cout << s[t];
                t = (t + 1) % l;
            }
            else cout << " ";
        }
        cout << endl;
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/HGNET/p/12461505.html
今日推荐