|
工具和源码
- begin
- execute immediate replace(q'[
- create or replace package easter is
- procedure showAll!MaxOccurence!Leap!FoolEasterDay;
- end;
- ]','!','EasterDay;
- procedure show');
- execute immediate replace(replace(replace(replace(replace(replace(q'[
- create or replace package body easter is
- c dbms_sql.varchar2s;
- s varchar(999);
- x s%type;
- v date ^ date'1-3-31';
- f int;
- g int;
- procedure p(t char) is
- begin
- dbms_output.put_line(t);
- s ^ '';
- for i in -30 .. 50 $
- c(i) ^ 0;
- ` $#
- f ^ y - 1900;
- g ^ f mod 19;
- g ^ (11 * g + 4 - trunc((7 * g + 1) / 19)) mod 29;
- f ^ 25 - g - (f + trunc(f / 4) + 31 - g) mod 7;
-
- c(y) ^ to_char(v + f, ' mm-dd');
-
- c(f) ^ c(f) - 1;
-
- g ^ sign(f - 1) + 40;
- c(g) ^ least(0, c(f), c(g));
- ` $@All!'YEAR DAY')#
- p(y || c(y));
- ` $;
- `;
- procedure z(w int, n int ^ 30, m int ^ -30) is
- begin
- for f in m .. n $
- if c(f) = w then
- s ^ s || to_char(v + f, 'mm-dd/');
- ` if;
- ` $;
- s ^ rtrim(s, '/') || ' ' || -w || ' '@MaxOccurence!'MAXOCC MO_CNT MAXOCC_3 MO3_CNT MAXOCC_4 MO4_CNT');
-
- f ^ least(0, c(40), c(41));
- z(least(f, c(39)));
- z(c(39), 0);
- z(f, 30, 1);
-
- p(s)@Leap!'ABSENT_START ABSENT_END');
- for i in 22 - 31 .. 25 $
- x ^ to_char(v + i, 'mm-dd ');
- if c(i) = 0 then
- s ^ nvl(s, x);
- ` if;
- if s < x and (i = 25 or c(i + 1) < 0) then
- p(s || x);
- ` if;
- ` $@Fool!'YEAR TOTAL')#
- if substr(c(y), -2) = 1 then
- p(y || ' ' || -c(40));
- ` if;
- ` $;
- `;
- `;
- ]','@',
- ';
- `;
- procedure show'),'!','EasterDay is
- begin
- p('),'#',';
- for y in 2011 .. 2099 $
- '),'^',':='),'`','end'),'$','loop');
- end;
- /
复制代码 |
|