oracle mini project

oracle pl/sql mini project

1.解一元二次方程 (x2+4x+3=0)

set serveroutput on 
declare 
a number ;
b number;
c number;
x1 number(10,2);
x2 number(10,2);
d number;
begin 
a:=1;
b:=4;
c:=3;
d:=b*b -4*a*c;
if(a=0) then 
x1 := -(c/b);
dbms_output.put_line('此时只有一个根 '|| x1);
elsif d<0 then  
  dbms_output.put_line('此时没有根 ');
  else
    -- 第一个根
    x1 := (-b+sqrt(d))/(2*a);
    x2 := (-b-sqrt(d))/(2*a);
    dbms_output.put_line('x1 : '||x1);
    dbms_output.put_line('x2 : '||x2);
end if;
end;

2.求100以内的质数的优化版实现

先记录在这里,后面会做的

posted @ 2016-08-28 18:56  牵牛花  阅读(179)  评论(0编辑  收藏  举报