//左边奇数右边偶数 void Swap(int* a, int* b) {int tmp = *b;*b = *a;*a = tmp; } void LeftRight(int arr[],int n) {int i = 0;int j = n - 1;while(i<j){if (arr[i] % 2 == 0 && arr[j] % 2 == 1) {Swap(&arr[i], &arr[j]);i++;j--;}else if (arr[i] % 2 == 1 && arr[j]%2== 1) {i++;}else if (arr[i] % 2 == 0 && arr[j]%2== 0) {j--;}else if (arr[i] % 2 == 1 && arr[j]%2== 0) {i++;j--;}} } int main() {int arr[20] = { 0 };//默认最大输入长度不超过20int n = 0;printf("请输入数组长度n:");scanf("%d", &n);int i = 0;printf("\n请输入数组数据:");for (i = 0;i < n;i++){scanf("%d", &arr[i]);}printf("\n调整后的数组为:");LeftRight(arr, n);for (i = 0;i < n;i++){printf("%d ", arr[i]);} }