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

72
16 - Stack/ex1.c Normal file
View File

@@ -0,0 +1,72 @@
#include "Lib.h"
//---------------------------------------------------------------------------------------
// Exc1a
// -----
//
// General : The function checks when the order in the stack is turn over.
//
// Parameters : s - A stack with numbers inside.(in)
//
// Return Value : The value in the stack when the order is turned over.
//
//---------------------------------------------------------------------------------------
// Programer : Cohen Idan
// Student No. : 211675038
// Date : 05.12.2019
//---------------------------------------------------------------------------------------
int SectionOne(stack * sk)
{
stack temp_sk;
InitializeStack(&temp_sk);
CopyStack(&temp_sk, sk);
int last_number = PopStack(&temp_sk).int_;
int this_number = PopStack(&temp_sk).int_;
while (this_number >= last_number)
{
last_number = this_number;
this_number = PopStack(&temp_sk).int_;
}
return (this_number);
}
//---------------------------------------------------------------------------------------
// Exc1b
// -----
//
// General : The function checks when the order in the stack is turn over.
//
// Parameters : s - A stack with numbers inside.(in)
//
// Return Value : The position in the stack when the order is turned over.
//
//---------------------------------------------------------------------------------------
// Programer : Cohen Idan
// Student No. : 211675038
// Date : 05.12.2019
//---------------------------------------------------------------------------------------
int SectionOne(stack * sk)
{
stack temp_sk;
InitializeStack(&temp_sk);
CopyStack(&temp_sk, sk);
unsigned int counter = ZERO;
int number = SectionOne(&temp_sk);
while (PopStack(&temp_sk).int_ != number)
{
counter++;
}
return (counter);
}
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);
}