【发布时间】:2013-11-19 15:40:20
【问题描述】:
我想画一个心形,里面有字,明天给朋友一个惊喜,但我不知道如何把字放在心上。我只能画心形
画心的代码
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double x,y;
double size=10;
for (x=0;x<size;x++)
{
for (y=0;y<=4*size;y++)
{
double dist1 = sqrt( pow(x-size,2) + pow(y-size,2) );
double dist2 = sqrt( pow(x-size,2) + pow(y-3*size,2) );
if (dist1 < size + 0.5 || dist2 < size + 0.5 )
cout<<"V";
else
cout<<" ";
}
cout<<endl;
}
for ( x=1;x<2*size;x++)
{
for(y=0;y<x;y++)
cout<<" ";
for (y=0; y<4*size + 1 - 2*x; y++)
cout<<"V";
cout<<endl;
}
system("PAUSE");
}
我需要帮助将单词放入心形
【问题讨论】:
-
提示:将使用字母代替您输出的某些空格。
-
为什么不将值静态存储在 char 数组中,或者您希望心脏的消息/大小是动态的?
-
使用文本编辑器而不是程序可能会容易得多。