oracle快排
DECLARE
TYPE num_tt IS TABLE OF INT;
num_t num_tt:=num_tt();
PROCEDURE quick_sort(arr_t IN OUT num_tt, i IN INT, j IN INT)
AS
tmp_i INT := i;
tmp_j INT := j;
fir_num INT;
BEGIN
IF(i < j) THEN
fir_num := arr_t(tmp_i);
WHILE(tmp_i < tmp_j) LOOP
WHILE(tmp_i < tmp_j AND fir_num < arr_t(tmp_j)) LOOP
tmp_j := tmp_j - 1;
END LOOP;
arr_t(tmp_i) := arr_t(tmp_j);
WHILE(tmp_i < tmp_j AND fir_num > arr_t(tmp_i)) LOOP
tmp_i := tmp_i + 1;
END LOOP;
arr_t(tmp_j) := arr_t(tmp_i);
END LOOP;
arr_t(tmp_i) := fir_num;
quick_sort(arr_t, i, tmp_i-1);
quick_sort(arr_t, tmp_i+1, j);
END IF;
END quick_sort;
BEGIN
num_t.extend(20);
FOR i IN 1..20 LOOP
num_t(i) := trunc(dbms_random.value(200,100000));
END LOOP;
dbms_output.put_line('before sort:');
FOR i IN 1..num_t.count LOOP
dbms_output.put_line(num_t(i)||',');
END LOOP;
quick_sort(num_t, 1, num_t.count);
dbms_output.put_line('after sort:');
FOR i IN 1..num_t.count LOOP
dbms_output.put_line(num_t(i)||',');
END LOOP;
END;
创新互联专注于霍城网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供霍城营销型网站建设,霍城网站制作、霍城网页设计、霍城网站官网定制、成都微信小程序服务,打造霍城网络公司原创品牌,更为您提供霍城网站排名全网营销落地服务。
新闻标题:oracle快排
URL分享:http://pwwzsj.com/article/gcciod.html