This commit is contained in:
2025-09-15 21:12:04 +08:00
commit 3f58f483ff
144 changed files with 5298 additions and 0 deletions

25
we/24-3.h Normal file
View File

@@ -0,0 +1,25 @@
struct List{
int val;
struct List * next;
};
void bubbleListSort(List *head) {
if (head == nullptr) return; // 空链表检查
List *temp2;
int temp;
bool swapped;
do {
swapped = false;
temp2 = head;
while (temp2->next) {
if (temp2->next->val < temp2->val) {
temp = temp2->val;
temp2->val = temp2->next->val;
temp2->next->val = temp;
swapped = true;
}
temp2 = temp2->next;
}
} while (swapped); // 如果没有发生交换,提前结束
}