Change for loop in comb_sort.c

It can be compiled and passed in C89.
This commit is contained in:
StephenCurry 2019-08-25 19:15:06 +08:00 committed by GitHub
parent 9a75c4e850
commit f14320d137
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,7 +24,8 @@ void sort (int *numbers, int size)
void display(int *array, int n)
{
for (int i = 0; i < n; ++i)
int i;
for (i = 0; i < n; ++i)
printf("%d ", array[i]);
printf("\n");
}
@ -34,7 +35,8 @@ int main()
int size = 6;
int *numbers = malloc(size*sizeof(int));
printf("Insert %d unsorted numbers: \n", size);
for (int i = 0; i < size; ++i)
int i;
for (i = 0; i < size; ++i)
scanf("%d", &numbers[i]);
printf("Initial array: ");
display(numbers, size);