码迷,mamicode.com
首页 > 编程语言 > 详细

c++打印心形

时间:2015-08-07 18:31:09      阅读:421      评论:0      收藏:0      [点我收藏+]

标签:

用c++打印一个心形的图案:
 1 #include<iostream>
 2 #include<cmath>
 3 using namespace std;
 4 int main()
 5 {
 6     float x, y;
 7     for (y = 1.5f; y >-1.5f; y -= 0.1f)
 8     {
 9         for (x = -1.5f; x <1.5f; x += 0.05f)
10         {
11             float a = x*x + y*y - 1;
12             if ((a*a*a- x*x*y*y*y)<=0)//心形方程
13                 cout << *;
14             else cout << " ";
15         }
16         cout << endl;
17     }
18     return 0;
19 }


效果图如下:
技术分享

c++打印心形

标签:

原文地址:http://www.cnblogs.com/lxh-boke/p/4711281.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!