/
test8.c
72 lines (69 loc) · 2.05 KB
/
test8.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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "DiList.h"
int main(void) {
List lista;
ListNode temp_node;
int i;
double temp_array[6];
lista = create();
if(add(&lista, 1, 10.5) == -1)
{
printf("apetuxe h eisagwgh neou stoixeiou sti listas\n");
return 0;
}
if(add(&lista, 2, 76) == -1)
{
printf("apetuxe h eisagwgh neou stoixeiou sti listas\n");
return 0;
}
if(add(&lista, 1, 63) == -1)
{
printf("apetuxe h eisagwgh neou stoixeiou sti listas\n");
return 0;
}
if(add(&lista, 3, 109.73) == -1)
{
printf("apetuxe h eisagwgh neou stoixeiou sti listas\n");
return 0;
}
if(add(&lista, 2, 1903.78) == -1)
{
printf("apetuxe h eisagwgh neou stoixeiou sti listas\n");
return 0;
}
if(add(&lista, 6, 7.5) == -1)
{
printf("apetuxe h eisagwgh neou stoixeiou sti listas\n");
return 0;
}
// PrintAll(lista); //63, 1903.78, 10.5, 109.73, 76, 7.5
i=1;
temp_node=lista.Head;
while(i<=lista.megethos){
temp_array[i-1]=temp_node->dedomena;
i=i+1;
temp_node=temp_node->epomenos;
}
reverse(&lista);
temp_node=lista.Head;
for(i=0;i<6;i++){
if(temp_array[5-i]!=temp_node->dedomena)
break;
else{
temp_node=temp_node->epomenos;
}
}
if(i==6)
printf("OK\n");
else
printf("Error\n");
// printf("\nlista meta tin antistrofi:\n\n");
// PrintAll(lista);
// reverse(&lista);
// printf("\nlista meta tin antistrofi:\n\n");
// PrintAll(lista);
destroy(&lista);
return 1;
}