|
贴出我的SQL语句, 其中数字20表示五角星每一条边上的点的个数(你也可以设置的大一些或小一些), 其中的数字5表示五角星的边数, 其中的数字2是为了调整横向字符间距与纵向行距之间的差异而设置的, 你也可以不乘以这个2, 这里只是为了输出稍微好看一些.
调整期中数字5, 你还可以输出7角星, 9角星.... 注意我的SQL不能输出6角星,8角星哟 因为我的SQL算法中是以一笔画能够画成的星为基础设计的算法的.
with a as (
select distinct round(sum(x) over(order by n)) x,
round(sum(y) over(order by n)) y
from (select n,
cos(trunc(n / 20) * (1-1/5) * 3.1415926) * 2 x,
sin(trunc(n / 20) * (1-1/5) * 3.1415926) y
from (select rownum - 1 n from all_objects where rownum <= 20 * 5))
)
select replace(sys_connect_by_path(point, '/'), '/', null) star
from (select b.y, b.x, decode(a.x, null, ' ', '*') point
from a,
(select *
from (select rownum - 1 + (select min(x) from a) x
from all_objects
where rownum <= (select max(x) - min(x) + 1 from a)),
(select rownum - 1 + (select min(y) from a) y
from all_objects
where rownum <= (select max(y) - min(y) + 1 from a))) b
where a.x(+) = b.x
and a.y(+) = b.y)
where x = (select max(x) from a)
start with x = (select min(x) from a)
connect by y = prior y
and x = prior x + 1;
给一个7角星图:
[ 本帖最后由 nyfor 于 2008-5-4 20:06 编辑 ] |
|