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

62
16 - Stack/ex3.c Normal file
View File

@@ -0,0 +1,62 @@
#include "Lib.h"
void DeleteItem(stack * sk, Data_Type item)
{
Data_Type temp_item;
stack temp_sk;
InitializeStack(&temp_sk);
while (!IsEmptyStack(sk))
{
temp_item = PopStack(sk);
if (temp_item.int_ != item.int_)
{
PushStack(&temp_sk, temp_item);
}
}
while (!IsEmptyStack(&temp_sk))
{
PushStack(sk, PopStack(&temp_sk));
}
}
void DeleteDuplicates(stack * sk)
{
Data_Type item;
stack temp_sk;
InitializeStack(&temp_sk);
while (!IsEmptyStack(sk))
{
item = PopStack(sk);
DeleteItem(sk, item);
PushStack(&temp_sk, item);
}
while (!IsEmptyStack(&temp_sk))
{
PushStack(sk, PopStack(&temp_sk));
}
}
//---------------------------------------------------------------------------------------
// Exc3
// ----
//
// General : The function delete the duplicate numbers from the stack.
//
// Parameters : s - A stack with numbers inside.(in)
//
// Return Value : The stack without the duplicated numbers.
//
//---------------------------------------------------------------------------------------
// Programer : Cohen Idan
// Student No. : 211675038
// Date : 05.12.2019
//---------------------------------------------------------------------------------------
void main(void)
{
stack s;
InitializeStack(&s);
Data_Type num1 = {.int_ = 4}, num2 = {.int_ = 5}, num3 = {.int_ = 6};
PushStack(&s, num1);
PushStack(&s, num2);
PushStack(&s, num3);
}