-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.c
64 lines (54 loc) · 1.34 KB
/
list.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* Program file name : list.c
* Description : definisi dari header file list untuk struktur data linked list pada program Kakuraato.
* Author : Husna Maulana, 211524045
* Compiler : GCC
*
*/
#include "list.h"
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
void CreateList(List *L)
{
L->root = Nil;
}
address Alokasi(char* expression, double result, char* timeOfCalculation)
{
address newItem = (address)malloc(sizeof(NodeList));
if (newItem != Nil)
{
strcpy(newItem->expression, expression);
newItem->result = result;
strcpy(newItem->timeEnteringExpression, timeOfCalculation);
newItem->next = Nil;
}
return newItem;
}
void InsLast (List *L, char* expression, double result, char* timeOfCalculation) {
address NodeLast = Alokasi(expression, result, timeOfCalculation);
address tmp =L->root;
if (NodeLast != Nil)
{
if(tmp != Nil){
while (tmp->next != Nil)
{
tmp = tmp->next;
}
tmp->next = NodeLast;
} else {
L->root = NodeLast;
}
}
}
void PrintInfo (List L) {
address tmp = L.root;
if (L.root != Nil) {
while (tmp != Nil)
{
printf("%s\n", tmp->expression);
tmp = tmp->next;
}
}
}