标签:
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); } }
标签:
原文地址:http://www.cnblogs.com/yixianyong/p/4557534.html