mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-14 02:10:37 +08:00
feat(codes/c): add C include/ codes and modify exist C codes
This commit is contained in:
2
codes/c/chapter_sorting/CMakeLists.txt
Normal file
2
codes/c/chapter_sorting/CMakeLists.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
add_executable(bubble_sort bubble_sort.c)
|
||||
add_executable(insertion_sort insertion_sort.c)
|
||||
@@ -50,14 +50,14 @@ void bubble_sort_with_flag(int nums[], int size) {
|
||||
/* Driver Code */
|
||||
int main() {
|
||||
int nums[6] = {4, 1, 3, 1, 5, 2};
|
||||
printf("冒泡排序后:\n");
|
||||
printf("冒泡排序后: ");
|
||||
bubble_sort(nums, 6);
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
printf("%d ", nums[i]);
|
||||
}
|
||||
|
||||
printf("优化版冒泡排序后:\n");
|
||||
printf("\n优化版冒泡排序后: ");
|
||||
bubble_sort_with_flag(nums, 6);
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ void insertionSort(int nums[], int size) {
|
||||
int main() {
|
||||
int nums[] = {4, 1, 3, 1, 5, 2};
|
||||
insertionSort(nums, 6);
|
||||
printf("插入排序完成后 nums = \n");
|
||||
printf("插入排序完成后 nums = ");
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
printf("%d ", nums[i]);
|
||||
|
||||
Reference in New Issue
Block a user