/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
///funkcje //////////////////////////////////////////////////////////////
void print (int t[], size_t size,const char* name) {
std::cout<<name;
for (size_t i = 0; i < size;i++) std::cout<< t[i]<<", ";
std::cout<<std::endl;
return;
}
///main //////////////////////////////////////////////////////////////
int main () {
int tab[] = { 3, 4, 2, 3, 7, 2, 9 };
size_t rozmiar = sizeof (tab) / sizeof (tab[0]);
int *a = tab;
int *b = tab + rozmiar - 1;
while (a < b) {
if (*b % 2 != 0 and * a % 2 == 0) std::swap (*a, *b);
while(*b % 2 == 0) b--;
while (*a % 2 != 0) a++;
}
b++;
a=tab;
print (tab, rozmiar,"Tablica: ");
print (a, (b-a),"Nieparzyste: ");
print (b, (a+rozmiar)-b,"Parzyste: ");
return 0;
}
//////////////////////////////////////////////////////////////