Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Just for fun

Just for fun

From: <t_adolph_at_hotmail.com>
Date: Sat, 5 Nov 2005 16:51:26 +0100
Message-ID: <BAY103-DAV4F6B2BC1A181C1E7F0882FA630@phx.gbl>


Hi all,

Its Saturday afternoon, its raining and the rugby doesn't start for a while, so....

create or replace procedure circle is
 pi constant number(5,3) := 3.142;
 screenWidth int := 40;
  radius int := screenWidth / 2;
  spot char(1) := '*';
  p1 number;
  p2 number;
  row int;
begin
 for row in 0 .. screenWidth
 loop

      p1 := round(radius - (radius * sin(acos((radius-row)/radius)))) 
         + 1; -- add 1 as lpad(char,0) doesn't print a char
      p2 := (radius - p1) * 2;
      dbms_output.put_line(lpad(spot,p1)--||lpad(spot,p2)
                           ||case when p2 = 1 then null else lpad(spot,p2) end
                           ||'('||row||','||p1||'),('||row||','|| to_char(p1 + p2) ||')'  
                           );

 end loop;
  exception
     when others then
       raise_application_error(-20000,
            'Ohps: something went pair shaped at '||
            '('||row||','||p1||'),('||row||','|| to_char(p1 + p2) ||')'
          );

end circle;

Why's my circle look like a rugby ball.. is it a sign from the gods that the game's just about to start? Or is my formual wrong or is it just the dodgy screen printing technique?

Have a good weekend
Cheers
Tony

PS Come on Wales and that's coming from an English man!

--
http://www.freelists.org/webpage/oracle-l
Received on Sat Nov 05 2005 - 09:51:50 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US