mirror of
https://github.com/142vip/408CSFamily.git
synced 2026-04-03 02:28:54 +08:00
feat: update
This commit is contained in:
@@ -1,15 +1,11 @@
|
||||
// 冒泡排序
|
||||
void BubbleSwapSort(ElemType A[], int n){
|
||||
|
||||
for(i=0;i<n-1;i++){
|
||||
|
||||
|
||||
// 当前趟次冒泡,是否发生了元素交换,初始化为false
|
||||
bool flag=false;
|
||||
|
||||
for(j=n-1;j>i;j--){
|
||||
if(A[j-1].key>A[j].key){
|
||||
|
||||
// 将两个元素A[j-1]、A[j]进行交换,有多种方法
|
||||
swap(A[j-1],A[j])
|
||||
// 确认已发生交换
|
||||
@@ -26,7 +22,6 @@ void BubbleSwapSort(ElemType A[], int n){
|
||||
|
||||
/**
|
||||
* 加减法实现两个元素值互换
|
||||
*
|
||||
*/
|
||||
void swap(int a, int b){
|
||||
// 此时a为两值的和
|
||||
@@ -37,10 +32,8 @@ void swap(int a, int b){
|
||||
a=a-b;
|
||||
}
|
||||
|
||||
/**
|
||||
* 临时变量实现两个元素值的互换
|
||||
*
|
||||
*/
|
||||
|
||||
// 临时变量实现两个元素值的互换
|
||||
void swap(int a,int b){
|
||||
int temp;
|
||||
temp=a;
|
||||
|
||||
Reference in New Issue
Block a user