First Upload
This commit is contained in:
2089
18 - Lists/Lib.h
Normal file
2089
18 - Lists/Lib.h
Normal file
File diff suppressed because it is too large
Load Diff
BIN
18 - Lists/ex1
Normal file
BIN
18 - Lists/ex1
Normal file
Binary file not shown.
51
18 - Lists/ex1.c
Normal file
51
18 - Lists/ex1.c
Normal file
@@ -0,0 +1,51 @@
|
||||
#include "Lib.h"
|
||||
|
||||
#define ASTERISK '*'
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// MostInRow
|
||||
// ---------
|
||||
//
|
||||
// General : The function check who the longest word in
|
||||
// list
|
||||
//
|
||||
// Parameters : **manager - pointer linear Linked List(IN)
|
||||
//
|
||||
// Return Value : The function returns the pointer of the
|
||||
// beginning of the big word.
|
||||
//
|
||||
//------------------------------------------------------------
|
||||
// Programer : Cohen Idan
|
||||
// Student No. : 211675038
|
||||
// Date : 12.12.2019
|
||||
//------------------------------------------------------------
|
||||
LLL * MostInRow(LLL ** manager)
|
||||
{
|
||||
LLL * pos = *manager;
|
||||
LLL * max_word = pos;
|
||||
LLL * temp_word = pos;
|
||||
unsigned int max_count = ZERO;
|
||||
unsigned int temp_count = ZERO;
|
||||
while ((*pos).next != NULL)
|
||||
{
|
||||
if ((*pos).value.char_ == ASTERISK)
|
||||
{
|
||||
if (temp_count > max_count)
|
||||
{
|
||||
max_word = temp_word;
|
||||
max_count = temp_count;
|
||||
}
|
||||
temp_count = ZERO;
|
||||
temp_word = (*pos).next;
|
||||
}
|
||||
temp_count++;
|
||||
pos = (*pos).next;
|
||||
}
|
||||
|
||||
return (max_word);
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
|
||||
}
|
||||
BIN
18 - Lists/ex2
Normal file
BIN
18 - Lists/ex2
Normal file
Binary file not shown.
34
18 - Lists/ex2.c
Normal file
34
18 - Lists/ex2.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "Lib.h"
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// RemoveDuplicate
|
||||
// ---------------
|
||||
//
|
||||
// General : The function deletes the number of
|
||||
// repetitive characters and returns a list
|
||||
// that comes one instance of each character
|
||||
//
|
||||
// Parameters : **manager - pointer linear Linked List(IN)
|
||||
//
|
||||
// Return Value : None
|
||||
//
|
||||
//------------------------------------------------------------
|
||||
// Programer : Cohen Idan
|
||||
// Student No. : 211675038
|
||||
// Date : 12.12.2019
|
||||
//------------------------------------------------------------
|
||||
LLL * RemoveDuplicate(LLL ** manager)
|
||||
{
|
||||
unsigned short arr[TEN] = { ZERO };
|
||||
LLL * pos = *manager;
|
||||
while ((*pos).next != NULL)
|
||||
{
|
||||
(arr[(*(*pos).next).value.int_] == ONE) ? DeleteList(pos) : arr[(*(*pos).next).value.int_]++;
|
||||
pos = (*pos).next;
|
||||
}
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
|
||||
}
|
||||
BIN
18 - Lists/ex3
Normal file
BIN
18 - Lists/ex3
Normal file
Binary file not shown.
65
18 - Lists/ex3.c
Normal file
65
18 - Lists/ex3.c
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "Lib.h"
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// SumOfNextLLL
|
||||
// ------------
|
||||
//
|
||||
// General : The function summarizes it from the current
|
||||
// position to the end of the list and puts it in
|
||||
// the position of the array so that the first organ
|
||||
// in the array contains the largest amount
|
||||
//
|
||||
// Parameters : **manager - pointer linear Linked List(IN)
|
||||
// *ptr_vec - vector of int(IN)
|
||||
//
|
||||
// Return Value : None
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
// Programer : Cohen Idan
|
||||
// Student No. : 211675038
|
||||
// Date : 12.12.2019
|
||||
//-------------------------------------------------------------------
|
||||
void SumOfNextLLL(LLL ** manager, int * ptr_vec)
|
||||
{
|
||||
LLL * temp = *manager;
|
||||
unsigned short length_list = ZERO;
|
||||
unsigned short length_vec = ZERO;
|
||||
while (temp != NULL)
|
||||
{
|
||||
while (length_vec--)
|
||||
{
|
||||
*(ptr_vec + length_vec) += (*temp).value.int_;;
|
||||
}
|
||||
length_vec = ++length_list;
|
||||
temp = (*temp).next;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
LLL * manager = NULL;
|
||||
PushList(&manager);
|
||||
PushList(&manager);
|
||||
PushList(&manager);
|
||||
PushList(&manager);
|
||||
PopList(&manager);
|
||||
printf("h\n");
|
||||
LLL * pos = manager;
|
||||
printf("h\n");
|
||||
(*pos).value.int_ = 10;
|
||||
printf("h\n");
|
||||
(*(*pos).next).value.int_ = 20;
|
||||
printf("h\n");
|
||||
(*(*(*pos).next).next).value.int_ = 30;
|
||||
printf("h\n");
|
||||
//(*(*(*(*pos).next).next).next).value.int_ = 40;
|
||||
|
||||
pos = manager;
|
||||
while (pos != NULL)
|
||||
{
|
||||
printf("%d\n" ,(*pos).value.int_);
|
||||
pos = (*pos).next;
|
||||
}
|
||||
|
||||
}
|
||||
41
18 - Lists/ex4.c
Normal file
41
18 - Lists/ex4.c
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "Lib.h"
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// LongestString
|
||||
// -------------
|
||||
//
|
||||
// General : The function check who the longest string in list
|
||||
//
|
||||
// Parameters : **manager - pointer linear Linked List(IN)
|
||||
//
|
||||
// Return Value : The index of longest string
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
// Programer : Cohen Idan
|
||||
// Student No. : 211675038
|
||||
// Date : 12.12.2019
|
||||
//-------------------------------------------------------------------
|
||||
LLL * LongestString(LLL ** manager)
|
||||
{
|
||||
LLL * runner = *manager;
|
||||
LLL * result = runner;
|
||||
unsigned int max = ZERO;
|
||||
unsigned int str_len = ZERO;
|
||||
while (runner != NULL)
|
||||
{
|
||||
str_len = StringLenght((*runner).value.pointer);
|
||||
if (str_len > max)
|
||||
{
|
||||
max = str_len;
|
||||
result = runner;
|
||||
}
|
||||
runner = (*runner).next;
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user