bayes_et_proba_condi.py

Created by joelkouakou2080

Created on March 13, 2024

1.09 KB


CREATE OR REPLACE PROCEDURE bubble_sort AS
    TYPE int_array IS TABLE OF INTEGER INDEX BY PLS_INTEGER;
    numbers int_array;
    temp INTEGER;
    swapped BOOLEAN;
BEGIN
    -- Initialisation de la liste
    numbers(1) := 64;
    numbers(2) := 34;
    numbers(3) := 25;
    numbers(4) := 12;
    numbers(5) := 22;
    numbers(6) := 11;
    numbers(7) := 90;

    -- Boucle principale du tri
    LOOP
        swapped := FALSE;
        FOR i IN 1..(numbers.COUNT - 1) LOOP
            IF numbers(i) > numbers(i + 1) THEN
                -- Échange des éléments en utilisant une variable temporaire
                temp := numbers(i);
                numbers(i) := numbers(i + 1);
                numbers(i + 1) := temp;
                swapped := TRUE;
            END IF;
        END LOOP;

        -- Si aucun échange n'a été effectué, la liste est triée
        EXIT WHEN NOT swapped;
    END LOOP;

    -- Affichage de la liste triée
    FOR i IN 1..numbers.COUNT LOOP
        DBMS_OUTPUT.PUT_LINE('numbers(' || i || ') = ' || numbers(i));
    END LOOP;
END bubble_sort;
/

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.