44 lines
1.2 KiB
C
44 lines
1.2 KiB
C
#include <stdio.h>
|
|
#include <malloc.h>
|
|
#include "PointersLibs.h"
|
|
|
|
int * EvenSubArray(int vec[], int len, int *ptr_even)
|
|
{
|
|
int * ptr_even_vec = (int)malloc(sizeof(int));
|
|
unsigned int counter;
|
|
for (counter = ZERO; counter < len; counter++)
|
|
{
|
|
if (!(vec[counter] % TWO))
|
|
{
|
|
(*ptr_even)++;
|
|
ptr_even_vec = realloc(ptr_even_vec, (*ptr_even));
|
|
*(ptr_even_vec++) = vec[counter];
|
|
}
|
|
}
|
|
|
|
return (ptr_even_vec);
|
|
}
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
// exe 1
|
|
// -----
|
|
//
|
|
// General : The program gets an array and separates the even
|
|
// numbers from it to the pointer.
|
|
//
|
|
// Input : an array of numbers, its length.
|
|
//
|
|
// Process : the program goes over the array and puts the even nums
|
|
// in the pointer array.
|
|
//
|
|
// Output : if there are even nums, and if there are, print them.
|
|
//
|
|
//---------------------------------------------------------------------------------------
|
|
// Proggramer : Cohen Idan
|
|
// Student No : 211675038
|
|
// Date : 21.11.19
|
|
//---------------------------------------------------------------------------------------
|
|
void main(void)
|
|
{
|
|
|
|
} |