First Upload
This commit is contained in:
44
12/ex1.c
Normal file
44
12/ex1.c
Normal file
@@ -0,0 +1,44 @@
|
||||
#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)
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user