First Upload

This commit is contained in:
2022-02-25 15:33:16 +02:00
commit 0c74d10f0d
295 changed files with 74784 additions and 0 deletions

48
12/ex4.c Normal file
View File

@@ -0,0 +1,48 @@
#include <stdio.h>
#include <malloc.h>
#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)
{
}