change the array initialization

This commit is contained in:
juan 2021-12-16 08:50:11 +08:00
parent a708a56310
commit 66238736d8
No known key found for this signature in database
GPG key ID: 5C1E5093C74F1DC7

View file

@ -32,10 +32,11 @@ int main(void) {
}
void sort(char **arr, int n) {
char *tmp;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - 1; j++) {
if (strcmp(arr[j], arr[j + 1]) > 0) {
char *tmp = arr[j];
tmp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = tmp;
}