4 תשובות
void even_odd_sort(int arr[], int n) {
int left = 0, right = n - 1;

while (left < right) {
// find the next even value from the left side
while (arr[left] % 2 == 0 && left < right) {
left++;
}

// find the next odd value from the right side
while (arr[right] % 2 != 0 && left < right) {
right--;
}

// swap the even and odd values
if (left < right) {
int temp = arr[left];
arr[left] = arr[right];
arr[right] = temp;
}
}
}
זה רק דוגמה.
שואל השאלה:
תודהה33>
אנונימית