给出完整的冒泡排序的C语言代码
时间: 2023-08-22 15:08:17 浏览: 69
关于冒泡排序的完整代码
以下是给出完整的冒泡排序的C语言代码:
```c
#include <stdio.h>
void bubbleSort(int arr[], int n) {
int i, j;
for (i = 0; i < n-1; i++) {
for (j = 0; j < n-i-1; j++) {
if (arr[j > arr[j+1]) {
int temp = arr[j];
arr[j = arr[j+1];
arr[j+1 = temp;
}
}
}
}
int main() {
int arr[] = {5, 2, 8, 12, 3};
int n = sizeof(arr) / sizeof(arr<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [c语言冒泡排序法代码(c语言冒泡排序法代码讲解)](https://blog.csdn.net/yetaodiao/article/details/127366700)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文