Browse Source

Ajout union

EyeXion 3 years ago
parent
commit
20974fba6d
2 changed files with 13 additions and 3 deletions
  1. 1
    1
      PILE/pile.c
  2. 12
    2
      PILE/pile.h

+ 1
- 1
PILE/pile.c View File

@@ -36,7 +36,7 @@ void init(struct pile ** une_pile) {
36 36
   *une_pile = (struct pile *)malloc(sizeof(struct pile));
37 37
 }
38 38
 
39
-void push(int e, struct pile * une_pile) {
39
+void push(Valeur e, struct pile * une_pile) {
40 40
   struct cell * aux;
41 41
   if (une_pile->taille == 0) {
42 42
     une_pile->taille = 1;

+ 12
- 2
PILE/pile.h View File

@@ -1,8 +1,18 @@
1 1
 #ifndef PILE_H
2 2
 #define PILE_H
3 3
   
4
+enum Type_t {reel,entier};
5
+
6
+typedef struct Valeur{
7
+    union
8
+    {
9
+        int valentier;
10
+        float valreel;
11
+    }val;
12
+    enum Type_t type;
13
+}Valeur;
4 14
 struct cell {
5
-  int val;
15
+  Valeur val;
6 16
   struct cell * suiv;
7 17
 };
8 18
 
@@ -13,7 +23,7 @@ struct pile {
13 23
 
14 24
 void init(struct pile ** une_pile);
15 25
 int pop(struct pile * une_pile);
16
-void push(int e, struct pile * une_pile);
26
+void push(Valeur e, struct pile * une_pile);
17 27
 void print(struct pile une_pile);
18 28
 
19 29
 #endif

Loading…
Cancel
Save