Leser: 1
5 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
struct knoten
{
string zeichenkette;
int knotennummer;
struct knoten *vor;
struct knoten *nach;
struct knoten *nach2;
};
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
79
80
81
82
83
84
85
86
87
88
knoten * einlesen()
{
string temp;
knoten *sicher;
knoten *tempit;
knoten *first;
int rein = 0;
int i=-1;
do
{
i++;
if(i==0)
{
cin >> temp;
first = new knoten;
first->knotennummer = i+1;
first->zeichenkette = temp;
first->vor = NULL;
first->nach = NULL;
first->nach2 = NULL;
}
sicher = first;
if(i>0)
{
cin >> temp;
tempit = new knoten;
tempit->knotennummer = i+1;
tempit->zeichenkette = temp;
tempit->vor = NULL;
while(rein == 0)
{
if (temp <= (sicher->zeichenkette))
{
if (sicher->nach == NULL)
{
sicher->nach = tempit;
tempit->vor = sicher;
tempit->nach = NULL;
tempit->nach2 = NULL;
rein = 1;
break;
}
else
{
sicher = sicher->nach;
}
}
if (temp > (sicher->zeichenkette))
{
if (sicher->nach2 == NULL)
{
sicher->nach2 = tempit;
tempit->vor = sicher;
tempit->nach = NULL;
tempit->nach2 = NULL;
rein = 1;
break;
}
else {
sicher = sicher->nach2;
}
}
rein = 0;
}
}
}
while((temp != "ENDE") && (i != MAXANZAHL-1));
return first;
}
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
struct Node
{
Node() : name(""), prev(0), next(0), last(0), id(0) {}
string name;
int id;
struct Node* prev;
struct Node* next;
struct Node* last;
}
Node* Node_pushback(Node* node, const string & name)
{
Node* ptr = 0;
ptr = new Node();
ptr->name = name;
if(node == 0)
{
node = ptr;
node->last = ptr;
}
else
{
ptr->id = node->last->id + 1;
node->last->next = ptr;
ptr->prev = node->last;
node->last = ptr;
}
return node;
}
void Node_delete(Node* node)
{
Node* run = 0;
while(run = node)
{
node = node->next;
delete run;
}
}
Node* Node_readin()
{
Node* node = 0;
string temp = "";
while(1)
{
cin >> temp;
if(temp == "ENDE") break;
node = Node_pushback(node, temp);
if(node->last->id == MAXANZAHL-1) break;
}
return node;
}
5 Einträge, 1 Seite |