-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ec2901
commit cba2f34
Showing
8 changed files
with
550 additions
and
84 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"inheritEnvironments": [ | ||
"msvc_x64" | ||
], | ||
"name": "x64-Debug", | ||
"includePath": [ | ||
"${env.INCLUDE}", | ||
"${workspaceRoot}\\**" | ||
], | ||
"defines": [ | ||
"WIN32", | ||
"_DEBUG", | ||
"UNICODE", | ||
"_UNICODE" | ||
], | ||
"intelliSenseMode": "windows-msvc-x64" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
int main() | ||
{ | ||
int i, j; | ||
char *name[] = {"HangZhou", "ShangHai", "GuangZhou", "BeiJing", "ShenZhen"}; | ||
char *pstr; | ||
|
||
// 冒泡排序算法对字符串数组进行升序排列 | ||
for (i = 0; i < 4; i++) { // 外层循环控制遍历次数 | ||
for (j = 0; j < 4 - i; j++) { // 内层循环比较相邻元素 | ||
if (strcmp(name[j], name[j + 1]) < 0) { // 如果前一个字符串大于后一个字符串,则交换 | ||
pstr = name[j]; | ||
name[j] = name[j + 1]; | ||
name[j + 1] = pstr; | ||
} | ||
} | ||
} | ||
|
||
// 输出排序后的字符串数组 | ||
for (i = 0; i < 5; i++) | ||
printf("%c\n", *name[i]); // 使用 %s 格式符打印字符串 | ||
|
||
for (i = 0; i < 5; i++) | ||
printf("%c\n", name[i][1]); // 使用 %s 格式符打印字符串 | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <stdio.h> | ||
|
||
void bubbleSort(int arr[], int n) { | ||
int i, j, temp; | ||
for (i = 0; i < n-1; i++) { | ||
for (j = 0; j < n-i-1; j++) { | ||
if (arr[j] > arr[j+1]) { | ||
// ½»»» arr[j] ºÍ arr[j+1] | ||
temp = arr[j]; | ||
arr[j] = arr[j+1]; | ||
arr[j+1] = temp; | ||
} | ||
} | ||
} | ||
} | ||
|
||
int main() { | ||
int arr[] = {64, 34, 25, 12, 22, 11, 90}; | ||
int n = sizeof(arr)/sizeof(arr[0]); | ||
bubbleSort(arr, n); | ||
printf("Sorted array: \n"); | ||
for (int i=0; i < n; i++) | ||
printf("%d ", arr[i]); | ||
return 0; | ||
} |
Oops, something went wrong.