-
Notifications
You must be signed in to change notification settings - Fork 0
/
TS.c
154 lines (143 loc) · 3.66 KB
/
TS.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
///Nom : M E G H N I
///Prénom : Mohamed El Amine
///Mat : 2015 0000 8875
///Section : SII G2
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
///Structure element
typedef struct element element;
struct element
{
char *Nom;
int type; ///Integer(1) or Real(0)
int nature; ///var(1) or const(0) or array(2)
int taille;
element *svt;
};
///____________________________________________________________________________________________________________
void inserer(element **liste,char *ch,int ty,int n,int taille)
{
element *nv = malloc(sizeof(element));
nv->Nom = ch;
nv->type = ty;
nv->nature = n;
nv->taille = taille;
if(*liste == NULL)
{
*liste = malloc(sizeof(element));
nv->svt = NULL;
*liste = nv;
}
else
{
element *r = *liste;
while(r->svt != NULL)
{
r = r->svt;
}
r->svt = nv;
nv->svt = NULL;
}
}
///____________________________________________________________________________________________________________
void insererTaille(element *liste,char *ch,int taille)
{
while(liste != NULL)
{
if(strcmp(liste->Nom,ch) == 0)
{
liste->taille = taille;
}
liste = liste->svt;
}
}
///___________________________________________________________________________________________
int chercher(element *liste,char *ch)///return 1 if found, 0 else
{
while(liste != NULL)
{
if(strcmp(liste->Nom,ch) == 0)
{
return 1;
}
else liste = liste->svt;
}
return 0;
}
///_____________________________________________________________________________________________________________
void afficher(element *liste)
{
int i = 1;
while(liste != NULL)
{
printf("------->DEC N %d\n",i);
printf("NOM : %s\n",liste->Nom);
if(liste->type == 1) printf("TYPE : ENTIER\n");
else printf("TYPE : REEL\n");
if(liste->nature == 1) printf("NATURE : VARIABLE\n");
else if (liste->nature == 0)printf("NATURE : CONSTANTE\n");
else
{
printf("NATURE : TABLEAU\n");
printf("Taille : %d\n",liste->taille);
}
printf("_____________________________________________\n\n");
liste = liste->svt;
i++;
}
}
///____________________________________________________________________________________________________________
int memeType(int a,int b)
{
if (a == b) return 1; else return 0;
}
///____________________________________________________________________________________________________________
int Type(element *list,char *ch)
{
while(list != NULL)
{
if(strcmp(list->Nom,ch) == 0)
{
return list->type;
}
else list = list->svt;
}
}
///____________________________________________________________________________________________________________
int Nature(element *list,char *ch)
{
while(list != NULL)
{
if(strcmp(list->Nom,ch) == 0)
{
return list->nature;
}
else list = list->svt;
}
}
///______________________________________________________________________________________________________
int getTailleArray(element *list,char *ch)
{
while(list!=NULL)
{
if(strcmp(list->Nom,ch) == 0)
{
return list->taille;
}
else list = list->svt;
}
}
//______________________________________________________________________________________________________
int IsArray(element *list,char *ch)
{
while(list!=NULL)
{
if(strcmp(list->Nom,ch) == 0)
{
if(list->taille != 0) return 1;
else return 0;
}
else list = list->svt;
}
}