This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Madame, monsieur, | |
| suite à la remise de la partie 3 de notre projet d'année en BA1 (INFO-F-106), | |
| une grande majorité de la classe de BA1 est dans le doute. | |
| Nous avons reçu un corrigé qui ne semble pas respecter entièrement les consignes du projet, | |
| et qui affiche des messages d'erreurs lors de l'exécution (sans gérer les exceptions). | |
| D'autre part, l'implémentation de certaines méthodes nous semble inappropriée: par exemple | |
| la méthode isDat (dans le module draughts.py) est incorrecte (elle peut renvoyer True si | |
| la sous-chaîne '.dat' se trouve ailleurs qu'en fin de chaîne), et elle utilise un "algorithme" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;Arbitrary values (aka constants) | |
| #define MIN #0x0008 | |
| #define MAX #0x00ff | |
| #define START #0x00ff | |
| #define True #0x01 | |
| #define False #0x00 | |
| ;Named registers (aka variables) | |
| #define GoUp R13 | |
| #define Thres R14 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def node2dot(tree): | |
| if tree.left: | |
| print('\t', tree.getRootVal(), '->', tree.left.getRootVal()) | |
| node2dot(tree.left) | |
| if tree.right: | |
| print('\t', tree.getRootVal(), '->', tree.right.getRootVal()) | |
| node2dot(tree.right) | |
| def tree2dot(tree, title='Arbre'): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Tree: | |
| def trig(self): | |
| # ... | |
| class SplitGame: | |
| def trig(self): | |
| self.tree.trig() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1 - 3 - 7 | |
| | | | |
| | 6 | |
| | | |
| 2 - 5 | |
| | | |
| 4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int a = 3; /* Variable de type "int", qui vaut 3 */ | |
| int *p = &a; /* Variable de type "pointeur sur int", qui vaut l'adresse de a (ex: 0xffffff58) */ | |
| int *n = NULL; /* Variable de type "pointeur sur int", initialisée à NULL (pointeur vide) */ | |
| /* | |
| En pratique, dans stdlib.h, on a | |
| #define NULL (void*)0 | |
| C'est à dire un pointeur générique (void *) vers l'adresse 0 de la mémoire. | |
| Tenter dy accéder fera planter le programme. | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CC = g++ | |
| CFLAGS = -Wall -Wextra | |
| OBJS = Tree.o SplitGame.o | |
| LDFLAGS = | |
| all: mainProjLang | |
| %.o : %.cpp | |
| ${CC} ${CFLAGS} -c -o $@ $< |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Categorie { | |
| public: | |
| int eleves; | |
| Categorie *options; | |
| } | |
| /* Allocation statique: deux objets Categorie sur la stack (voir cours FDO), ba1 et ba2 désignent les objets */ | |
| Categorie ba1, ba2; | |
| /* Allocation dynamique: un objet Categorie sur le heap, un pointeur sur la stack. options désigne l'adresse d'un objet */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Solution 1: getSubTree renvoie un pointeur sur pointeur sur arbre, | |
| autrement dit, l'adresse du pointeur sur le sous-arbre gauhe de l'objet. | |
| A éviter, puisqu'on permet d'écrire dans un atttribut privé. */ | |
| Tree **Tree::getSubTreeL(){ | |
| return &(this->leftChild); | |
| } | |
| /* Solution 2: implémenter un setter, à préferer */ | |
| void Tree::setSubTreeL(Tree *child){ | |
| this->leftChild = child; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <cstring> | |
| const char *longue_chaine = "Je suis une longue chaine de caracteres"; | |
| char dest[6] = ""; | |
| size_t N = 5; | |
| /* Equivalent de dest = longue_chaine[:5] en Python */ | |
| strncpy(dest, longue_chaine, N); | |
| dest[N] = '\0'; /* Si la chaine d'origine est plus longue que N de strncpy, | |
| la chaine de destination n'est pas terminée, faut le faire |