cau 2
-------------------CAU 2------------
CREATE OR REPLACE FUNCTION F_USCLN_BSCNN
(A IN INT,B IN INT,USCLN OUT INT,BSCNN OUT INT,M_MIN OUT INT) RETURN CHAR
IS
X INT :=ABS(A);
Y INT :=ABS(B);
FUNCTION F_MIN(SOA IN INT,SOB IN INT)RETURN INT
IS
SOMIN INT;
BEGIN
IF SOA>SOB THEN
SOMIN:=SOA;
ELSE
SOMIN:=SOB;
END IF;
RETURN SOMIN;
END F_MIN;
PROCEDURE P_USCLN_BSCNN(US OUT INT,BS OUT INT)
IS
BEGIN
WHILE X*Y<>0
LOOP
IF(X>Y) THEN
X:=X-Y;
ELSE
Y:=Y-X;
END IF;
END LOOP;
US:=X+Y;
BS:=(A*B)/(X+Y);
END P_USCLN_BSCNN;
BEGIN
M_MIN:=F_MIN(A,B);
P_USCLN_BSCNN(USCLN,BSCNN);
RETURN 'BSCNN ='||BSCNN||' USCLL ='||USCLN||' MIN='||M_MIN;
END;
----GỌI THỰC THI------------
SET SERVEROUTPUT ON
DECLARE
SOA INT:=2;
SOB INT:=3;
US INT;
BS INT;
SOMIN INT;
BEGIN
DBMS_OUTPUT.PUT_LINE(TO_CHAR(F_USCLN_BSCNN(SOA,SOB,US,BS,SOMIN)));
END;
Bạn đang đọc truyện trên: AzTruyen.Top