65 lines
1.7 KiB
C
65 lines
1.7 KiB
C
#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;
|
|
}
|
|
|
|
} |