Download benchmarks/Algorithms/bubble_sort/solution.c from PV-SJTU/PV-Bench: direct link, hf CLI and curl.
- Browser
- Download file 440 Bytes
-
https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Algorithms/bubble_sort/solution.c
- Command line
-
hf download hf://datasets/PV-SJTU/PV-Bench/benchmarks/Algorithms/bubble_sort/solution.c
-
curl -L -o solution.c https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Algorithms/bubble_sort/solution.c
440 Bytes
| int* sortArray(int* nums, int numsSize, int* returnSize) | |
| { | |
| *returnSize = numsSize; | |
| if (numsSize <= 1) { | |
| return nums; | |
| } | |
| for (int i = 0; i < numsSize - 1; ++i) { | |
| for (int j = 0; j + 1 < numsSize - i; ++j) { | |
| if (nums[j] > nums[j + 1]) { | |
| int tmp = nums[j]; | |
| nums[j] = nums[j + 1]; | |
| nums[j + 1] = tmp; | |
| } | |
| } | |
| } | |
| return nums; | |
| } | |