【发布时间】:2018-12-08 15:11:29
【问题描述】:
我想对我的作业使用冒泡排序方法,它不起作用,我找不到错误
void bubbleSort(int arr[], int n)
{
int i,j;
for (i = 0; i < n-1; i++)
// last i elements are already in place
for (j = 0; j < n-i; j++)
if (arr[j] > arr[j+1])
swap(&arr[j], &arr[j+1]);
}
有人可以帮助我吗?提前致谢
【问题讨论】:
-
欢迎来到 Stack Overflow。请阅读the help pages、the SO tour、阅读how to ask good questions,以及this question checklist。另请了解如何创建minimal reproducible example。最后请learn how to debug your programs
标签: c sorting bubble-sort