#include #include #include "PointersLibs.h" void EvenAndOddToTwoVec(int vec[], unsigned short vec_size, int *evensize, int *oddsize, int **even, int **odd) { *even = malloc(sizeof(int)); *odd = malloc(sizeof(int)); *evensize = ZERO; *oddsize = ZERO; unsigned short counter; for (counter = ZERO; counter < vec_size; counter++) { if (!(vec[counter] % TWO)) { *even = realloc(*even, ++(*evensize)); *((*even) + (*evensize) - ONE) = vec[counter]; } else { *odd = realloc(*odd, ++(*oddsize)); *((*odd) + (*oddsize) - ONE) = vec[counter]; } } } //--------------------------------------------------------------------------------------- // exe 4 // ----- // General : the program gets an array of numbers, and breaks it // down to even numbers and odd numbers. // // Input : an array of numbers. // // Process : goes over the arrau and adds the even num to the even // pointer and the odd to odd pointer. // // Output : The even array and odd array. // //--------------------------------------------------------------------------------------- // Proggramer : Cohen Idan // Student No : 211675038 // Date : 21.11.19 //--------------------------------------------------------------------------------------- void main(void) { }