mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
index now starts from 1
This commit is contained in:
parent
90e6ee0771
commit
aac957c7a2
@ -6,17 +6,18 @@ void sort(int *numbers, int size)
|
||||
int pos = 0;
|
||||
while (pos < size)
|
||||
{
|
||||
if (numbers[pos] >= numbers[pos-1])
|
||||
if (pos == 0)
|
||||
pos = 1;
|
||||
if (numbers[pos] >= numbers[pos-1] && pos==0)
|
||||
pos++;
|
||||
else
|
||||
else
|
||||
{
|
||||
int tmp = numbers[pos-1];
|
||||
numbers[pos-1] = numbers[pos];
|
||||
numbers[pos] = tmp;
|
||||
pos--;
|
||||
|
||||
if (pos == 0)
|
||||
pos = 1;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -45,4 +46,3 @@ int main()
|
||||
free(numbers);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user