修改后的程序如下:
Tree(p1, p2, n, max)
{
L = Segment(p1, p2);
n = n + 1;
if (n > max) return max;
Hide(L);
p3 = DivisionPoint(p1, p2, 1/2);
p4 = DivisionPoint(p1, p2, 2);
p5 = PointFlexRotate(p4, p3,1,30);
p6 = PointFlexRotate(p2, p4,1,-30);
Hide(p1, p2, p3, p4, p5, p6);
i = n, j = n, k = n, u = n, v = n;
Tree(p1, p3, i, max);
n = i;
Tree(p3, p5, j, max);
n = j;
Tree(p3, p4, k, max);
n = k;
Tree(p4, p6, u, max);
n = u;
Tree(p4, p2, v, max);
n = v;
}
>> Tree(p1, p2, n, max) #
n = 0;
p1 = Point(0, -6);
p2 = Point(0, 6);
Tree(p1, p2, n, 4);
>> 5 #
执行后的结果与手册上的结果一致。 |