我想按降序排列他们的成绩。我只是不知道如何使用冒泡排序..
select count(concat(CODE_ID,MISC_FLAGS)) into count_of_plt_to_delete
from WHSE_SYS_CODE
where REC_TYPE = 'C'
and CODE_TYPE = 'PLT'
minus
select Count(concat(pcl.pkt_consol_value_1, lh.locn_brcd))
from pkt_consol_locn pcl
inner join locn_hdr lh on (lh.bay = pcl.pkt_consol_attr or pcl.pkt_consol_attr = concat(substr(lh.bay,1,1),substr(lh.bay,3,1))and lh.bay like '%0%' )
where lh.zone = 'PB'
and PKT_CONSOL_VALUE_1 is not null
and LOCN_CLASS = 'S' -- Rows in A that are not in B
union all
select count(concat(pcl.pkt_consol_value_1, lh.locn_brcd))
from pkt_consol_locn pcl
inner join locn_hdr lh on (lh.bay = pcl.pkt_consol_attr or pcl.pkt_consol_attr = concat(substr(lh.bay,1,1),substr(lh.bay,3,1))and lh.bay like '%0%' )
where lh.zone = 'PB'
and PKT_CONSOL_VALUE_1 is not null
and LOCN_CLASS = 'S'
minus
select count(concat(CODE_ID,MISC_FLAGS))
from WHSE_SYS_CODE
where REC_TYPE = 'C'
and CODE_TYPE = 'PLT';
select count(pkt_consol_value_1) into count_of_new_plt from pkt_consol_locn pcl
where pkt_consol_value_1 not in (select code_id from WHSE_SYS_CODE where REC_TYPE = 'C'
and CODE_TYPE = 'PLT')and PKT_CONSOL_VALUE_1 is not null;
--message:='We are adding'||PKT_CONSOL_VALUE_1||'new sys_code records';
dbms_output.put_line('You are Deleting '|| count_of_plt_to_delete || ' sys_code PLT records!! '|| count_of_new_plt || ' new sys_code PLT records are being added. Would you like to Proceed?');
END;
答案 0 :(得分:1)
我建议首先创建一个包含学生信息的结构或类,而不是单独传递所有数组。 完成后,您可以将包含学生的struct / class数组传递给函数,然后使用bubble-sort对数组进行排序,方法是比较成绩,然后交换整个struct / class。
student students[number_of_students];
//load the student data here
computegrate(students,top);
然后在函数内部进行比较并在必要时交换
if(students[i-1].ave < students[i].ave){
student temp = students[i-1];
students[i-1] = students[i];
students[i] = temp;
}
您应该熟悉bubble-sort的完整实现,如果没有,那么请检查您的教科书或笔记或一些在线教程。 您将不得不重写您的功能以吸引一大批学生。 好处是你不必处理所有的个人数据,而是整个结构,如图所示,交换2个学生对象。
如果没有类或结构,则必须在所有阵列中单独交换学生信息。