void Circle::print_char(int x1,int x2)
{
int i;
// 计算这一行的宽度,终端最多显示80列
int n = max(x1, x2) + 1;
n = n > 80 ? 80 : n;
for (i = 0; i < n; i++)
{
if (i == x1 || i == x2)
printf("*");
else
printf(" ");
}
printf("\n");
}
void Circle::Draw()
{
int r=(int)semidiameter;
int x1, x2, y;
int d = 2 * r;
int offset;
for(y = 0; y <= d; y++)
{
/*终端字符宽高比为2:1*/
offset = (int)(0.5 + sqrt((double)(r*r - (y-r)*(y-r)))*2.0);
x1 = d - offset;
x2 = d + offset;
print_char(x1, x2);
}
}
原文链接: https://www.cnblogs.com/yixianyong/p/4557534.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/217268
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!