Skip to content

Commit 261554f

Browse files
github-actions[bot]LY-Xiang
authored andcommitted
fixup! 小修改
1 parent de408e2 commit 261554f

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

docs/教程/正文/语法和标准库/18_算法库.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ void qsort(void *ptr, size_t count, size_t size, int (*compare)(const void *, co
1818
1919
其中:
2020
21-
+ `ptr` 是指向要排序的数组的指针;
22-
+ `count` 是数组中元素的个数;
23-
+ `size` 是数组中每个元素的大小;
24-
+ `compare` 是一个比较函数,用于确定数组中元素的顺序。
21+
- `ptr` 是指向要排序的数组的指针;
22+
- `count` 是数组中元素的个数;
23+
- `size` 是数组中每个元素的大小;
24+
- `compare` 是一个比较函数,用于确定数组中元素的顺序。
2525
2626
### 比较函数
2727
@@ -58,27 +58,27 @@ int compare(const void *a, const void *b) {
5858
#include <limits.h>
5959
#include <stdio.h>
6060
#include <stdlib.h>
61-
61+
6262
int compare_ints(const void* a, const void* b)
6363
{
6464
int arg1 = *(const int*)a;
6565
int arg2 = *(const int*)b;
66-
66+
6767
if (arg1 < arg2) return -1;
6868
if (arg1 > arg2) return 1;
6969
return 0;
7070
}
71-
71+
7272
int main(void)
7373
{
7474
int ints[] = {-2, 99, 0, -743, 2, INT_MIN, 4};
7575
size_t size = sizeof ints / sizeof ints[0];
76-
76+
7777
qsort(ints, size, sizeof(int), compare_ints);
78-
78+
7979
for (size_t i = 0; i < size; i++)
8080
printf("%d ", ints[i]);
81-
81+
8282
printf("\n");
8383
}
8484
```
@@ -173,4 +173,4 @@ void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, int
173173
174174
其中:
175175
176-
+ `key` 是指向要搜索的键值的指针;
176+
- `key` 是指向要搜索的键值的指针;

0 commit comments

Comments
 (0)