-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.c
78 lines (43 loc) · 1.52 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "list.h"
list *newlist(char *word, list *next){
list *newnode;
newnode = (list *) malloc(sizeof(list));
newnode->word = (char *) malloc(sizeof(char)*strlen(word));
strcpy(newnode->word, word);
newnode->next = next;
return newnode;
}
problemlist *newproblemlist(int order, char *pal1, char *pal2, int maxmut, problemlist *next){
problemlist *newsizenode;
newsizenode = (problemlist *) malloc(sizeof(problemlist));
newsizenode->order = order;
newsizenode->pal1 = (char *) malloc(sizeof(char)*strlen(pal1));
strcpy(newsizenode->pal1, pal1);
newsizenode->pal2 = (char *) malloc(sizeof(char)*strlen(pal2));
strcpy(newsizenode->pal2, pal2);
newsizenode->maxmut = maxmut;
newsizenode->next = next;
return newsizenode;
}
sizelist *newsizelist(int size, sizelist *next){
sizelist *newsizenode;
newsizenode = (sizelist *) malloc(sizeof(sizelist));
newsizenode->size = size;
newsizenode->next = next;
return newsizenode;
}
problemsol *newproblemsol(int weight, list *path){
problemsol *newproblemsolnode;
newproblemsolnode = (problemsol *) malloc(sizeof(problemsol));
newproblemsolnode->weight = weight;
newproblemsolnode->path = path;
return newproblemsolnode;
}
problemsol *newspecialsol(int weight, list *path, problemsol *next){
problemsol *newproblemsolnode;
newproblemsolnode = (problemsol *) malloc(sizeof(problemsol));
newproblemsolnode->weight = weight;
newproblemsolnode->path = path;
newproblemsolnode->next = next;
return newproblemsolnode;
}