diff --git a/DEV.1.1/CM3/Makefile b/DEV.1.1/CM3/Makefile new file mode 100644 index 0000000..9586dcf --- /dev/null +++ b/DEV.1.1/CM3/Makefile @@ -0,0 +1,40 @@ +### VARIABLES ### + +CC = gcc +CFLAGS = -Wall \ + -ansi \ + -pedantic + +EXE = exe +OFILES = ex3.o \ + queue.o \ + +### BUT PAR DEFAUT ### + +but : ${EXE} + +### REGLES ESSENTIELLES ### + +${EXE} : ${OFILES} + $(CC) $(CFLAGS) -o ${EXE} ${OFILES} + + +ex3.o : queue.h + +queue.o : queue.h + +### REGLES OPTIONNELLES ### + +run : but + ./${EXE} + +clean : + -rm -f ${OFILES} ${EXE} + +mrproper : clean but + +### BUTS FACTICES ### + +.PHONY : but clean mrproper + +### FIN ### \ No newline at end of file diff --git a/DEV.1.1/CM3/ex1 b/DEV.1.1/CM3/ex1 deleted file mode 100755 index 80c6595..0000000 Binary files a/DEV.1.1/CM3/ex1 and /dev/null differ diff --git a/DEV.1.1/CM3/ex2.c b/DEV.1.1/CM3/ex2.c index 26f02f3..f72db8a 100644 --- a/DEV.1.1/CM3/ex2.c +++ b/DEV.1.1/CM3/ex2.c @@ -22,12 +22,10 @@ int main(int argc, char *argv[]) { return EXIT_FAILURE; } - size_t read; + /* réecriture du texte dans le fichier temporaire en remplaçant les points d'interrogation grecs par des points-virgules*/ while(1){ - read = fread(buffer, sizeof(*buffer),file) - if("0xCD" || "0xBE") - if () { + if(fread(file) == "0xCD" || "0xBE"){ perror("Erreur d'écriture dans le fichier temporaire"); fclose(file); fclose(tempFile); diff --git a/DEV.1.1/CM3/ex3.c b/DEV.1.1/CM3/ex3.c new file mode 100644 index 0000000..47ea67e --- /dev/null +++ b/DEV.1.1/CM3/ex3.c @@ -0,0 +1,27 @@ +#include +#include +#include "queue.h" + +int main(int argc, char *argv[]){ + int i, ignores, somme; + + for(i=0;i<=argc;i++){ + if(argv[i]<10){ + + }else if(argv[i]>="a" || argv[i]<="z"){ + while(argv[i]!=" "){ + ignores = ignores + argv[i]; + } + ignores = ignores + " "; + + }else if(argv[i]<0 || argv[i]>0){ + while(argv[i]!=" "){ + somme = somme + argv[i]; + } + } + + } + + printf("somme : %d\n", somme); + printf("ignorés : %s\n", ignores) +} \ No newline at end of file diff --git a/DEV.1.1/CM3/queue.c b/DEV.1.1/CM3/queue.c new file mode 100644 index 0000000..16e8848 --- /dev/null +++ b/DEV.1.1/CM3/queue.c @@ -0,0 +1,69 @@ +#include +#include "queue.h" + +struct s_link { + unsigned value; + struct s_link *next; +}; + +typedef struct s_link link; + +struct s_queue { + link *first; /* sortie */ + link *last; /* entrée */ +}; + + +/* crée une file vide */ +queue create_queue(void) { + return (queue) calloc(1, sizeof(struct s_queue)); +} + +/* ajoute un élément à la file. Renvoie 0 en cas d'échec */ +int enqueue(queue the_queue, unsigned the_value) { + link *new = (link*) malloc(sizeof(link)); + if (new == NULL) { + return 0; + } + new->value = the_value; + new->next = NULL; + if (the_queue->last == NULL) { + the_queue->first = new; + } else { + the_queue->last->next = new; + } + the_queue->last = new; + return 1; +} + +/* renvoie 1 si la file est vide */ +int empty(queue the_queue) { + return the_queue->first == NULL; +} + +/* retire un élément de la file. Renvoie l'élément retiré, ou -1 en cas d'échec */ +long dequeue(queue the_queue) { + if(the_queue->first == NULL) { + return -1; + } + link l = *(the_queue->first); + free(the_queue->first); + the_queue->first = l.next; + if (the_queue->first == NULL) { + the_queue->last = NULL; + } + return l.value; +} + +/* détruit une file en libérant les ressources associées */ +void destroy_queue(queue the_queue) { + link *current, *saved; + + current = the_queue->first; + while(current != NULL) { + saved = current->next; + free(current); + current = saved; + } + free(the_queue); +} \ No newline at end of file diff --git a/DEV.1.1/CM3/queue.h b/DEV.1.1/CM3/queue.h new file mode 100644 index 0000000..067bc05 --- /dev/null +++ b/DEV.1.1/CM3/queue.h @@ -0,0 +1,22 @@ +#ifndef QUEUE_H +#define QUEUE_H + +/* le type queue représente une file */ +typedef struct s_queue *queue; + +/* crée une file vide. Renvoie NULL en cas d'échec */ +queue create_queue(void); + +/* ajoute un élément à la file. Renvoie 0 en cas d'échec */ +int enqueue(queue, unsigned); + +/* renvoie 1 si la file est vide */ +int empty(queue); + +/* retire un élément de la file. Renvoie l'élément retiré, ou -1 en cas d'échec */ +long dequeue(queue); + +/* détruit une file en libérant les ressources associées */ +void destroy_queue(queue); + +#endif /* QUEUE_H */ \ No newline at end of file diff --git a/DEV.1.1/Piles_et_Files/fonct.c b/DEV.1.1/Piles_et_Files/fonct.c new file mode 100644 index 0000000..7e05c12 --- /dev/null +++ b/DEV.1.1/Piles_et_Files/fonct.c @@ -0,0 +1,103 @@ +#include +#include +#include + +#define MAX_SIZE 50 + +typedef struct { + char tab[MAX_SIZE]; + int indice_debut; + int indice_fin; + int taille; +} pile; + +typedef struct maillon_s { + char valeur; + struct maillon_s* suivant; +} maillon; + +typedef struct { + maillon* tete; + maillon* queue; +} file; + +void push_pile(pile* p, char valeur) { + if (p->taille < MAX_SIZE) { + p->tab[p->taille++] = valeur; + } else { + printf("Erreur: pile pleine\n"); + } +} + +char pop_pile(pile* p) { + if (p->taille > 0) { + return p->tab[--p->taille]; + } + printf("Erreur: pile vide\n"); + return '\0'; +} + +int empty_pile(pile* p) { + return p->taille == 0; +} + +void enqueue_file(file* f, char valeur) { + maillon* nouveau = (maillon*)malloc(sizeof(maillon)); + if (nouveau == NULL) { + printf("Erreur: allocation memoire\n"); + exit(EXIT_FAILURE); + } + nouveau->valeur = valeur; + nouveau->suivant = NULL; + if (f->queue == NULL) { + f->tete = f->queue = nouveau; + } else { + f->queue->suivant = nouveau; + f->queue = nouveau; + } +} + +char dequeue_file(file* f) { + if (f->tete == NULL) { + printf("Erreur: file vide\n"); + return '\0'; + } + maillon* temp = f->tete; + char valeur = temp->valeur; + f->tete = f->tete->suivant; + if (f->tete == NULL) { + f->queue = NULL; + } + free(temp); + return valeur; +} + +int empty_file(file* f) { + return f->tete == NULL; +} + +int main(void) { + pile p = {{0}, 0, 0, 0}; + file f = {NULL, NULL}; + char ordre[2]; + + printf("La pile et la file attendent vos ordres \n > "); + while (scanf("%1s", ordre) == 1) { + if (ordre[0] == 'q') { + printf("Au revoir\n"); + break; + } else if (ordre[0] == '+') { + scanf(" %c", &ordre[1]); + push_pile(&p, ordre[1]); + enqueue_file(&f, ordre[1]); + } else if (ordre[0] == '-') { + printf("Pop: %c\n", pop_pile(&p)); + printf("Dequeue: %c\n", dequeue_file(&f)); + } else { + printf("Commande invalide\n"); + } + printf("\nLa pile et la file attendent vos ordres \n > "); + } + + return EXIT_SUCCESS; +} diff --git a/DEV.1.1/Piles_et_Files/fonct_file.c b/DEV.1.1/Piles_et_Files/fonct_file.c new file mode 100644 index 0000000..8de9864 --- /dev/null +++ b/DEV.1.1/Piles_et_Files/fonct_file.c @@ -0,0 +1,70 @@ +#include +#include + +typedef struct maillon_s { + char valeur; + struct maillon_s* suivant; +} maillon; + +typedef struct { + maillon* tete; + maillon* queue; +} file; + +void enqueue_file(file* f, char valeur) { + maillon* nouveau = (maillon*)malloc(sizeof(maillon)); + if (nouveau == NULL) { + printf("Erreur: allocation memoire\n"); + exit(EXIT_FAILURE); + } + nouveau->valeur = valeur; + nouveau->suivant = NULL; + if (f->queue == NULL) { + f->tete = f->queue = nouveau; + } else { + f->queue->suivant = nouveau; + f->queue = nouveau; + } +} + +char dequeue_file(file* f) { + if (f->tete == NULL) { + printf("Erreur: file vide\n"); + return '\0'; + } + maillon* temp = f->tete; + char valeur = temp->valeur; + f->tete = f->tete->suivant; + if (f->tete == NULL) { + f->queue = NULL; + } + free(temp); + return valeur; +} + +int empty_file(file* f) { + return f->tete == NULL; +} + +int main(void) { + file f = {NULL, NULL}; + char ordre[2]; + + printf("La file attend vos ordres \n > "); + while (scanf("%1s", ordre) == 1) { + if (ordre[0] == 'q') { + printf("Au revoir\n"); + break; + } else if (ordre[0] == '+') { + scanf(" %c", &ordre[1]); + enqueue_file(&f, ordre[1]); + } else if (ordre[0] == '-') { + printf("Dequeue: %c\n", dequeue_file(&f)); + } else { + printf("Commande invalide\n"); + } + printf("\nLa file attend vos ordres \n > "); + } + + return EXIT_SUCCESS; +} diff --git a/DEV.1.1/Piles_et_Files/fonct_pile.c b/DEV.1.1/Piles_et_Files/fonct_pile.c new file mode 100644 index 0000000..ace0bb1 --- /dev/null +++ b/DEV.1.1/Piles_et_Files/fonct_pile.c @@ -0,0 +1,52 @@ +#include +#include + +#define MAX_SIZE 50 + +typedef struct { + char tab[MAX_SIZE]; + int taille; +} pile; + +void push_pile(pile* p, char valeur) { + if (p->taille < MAX_SIZE) { + p->tab[p->taille++] = valeur; + } else { + printf("Erreur: pile pleine\n"); + } +} + +char pop_pile(pile* p) { + if (p->taille > 0) { + return p->tab[--p->taille]; + } + printf("Erreur: pile vide\n"); + return '\0'; +} + +int empty_pile(pile* p) { + return p->taille == 0; +} + +int main(void) { + pile p = {{0}, 0}; + char ordre[2]; + + printf("La pile attend vos ordres \n > "); + while (scanf("%1s", ordre) == 1) { + if (ordre[0] == 'q') { + printf("Au revoir\n"); + break; + } else if (ordre[0] == '+') { + scanf(" %c", &ordre[1]); + push_pile(&p, ordre[1]); + } else if (ordre[0] == '-') { + printf("Pop: %c\n", pop_pile(&p)); + } else { + printf("Commande invalide\n"); + } + printf("\nLa pile attend vos ordres \n > "); + } + + return EXIT_SUCCESS; +} diff --git a/DEV.1.1/srivasta_CM3.tar.gz b/DEV.1.1/srivasta_CM3.tar.gz new file mode 100644 index 0000000..72f557a Binary files /dev/null and b/DEV.1.1/srivasta_CM3.tar.gz differ diff --git a/DEV.1.2/tp4/pantheon.html b/DEV.1.2/tp4/pantheon.html new file mode 100644 index 0000000..2905587 --- /dev/null +++ b/DEV.1.2/tp4/pantheon.html @@ -0,0 +1,82 @@ + + + + + + TP mise en page avec le css + + + +
+

Mon Panthéon

+ +
+
+

Les informaticiens

+
+ Ritchie +

Dennis
Ritchie

+

9 septembre 1941 - 12 octobre 2011

Nationalité : américaine

+
+
+ linus torvalds +

Linus
Torvalds

+

28 décembre 1969 -

+

Nationalité : finlandaise

+
+
+ Pascal +

Blaise
Pascal

+

19 juin 1623 - 19 août 1662

+

Nationalité : française

+
+
+ turing +

Alan
Turing

+

23 juin 1912 - 7 juin 1954

+

Nationalité : britannique

+
+
+ + + + diff --git a/DEV.1.2/tp4/style.css b/DEV.1.2/tp4/style.css new file mode 100644 index 0000000..e69de29 diff --git a/DEV.2.1/TP/TP1-introduction/Arguments.java b/DEV.2.1/TP/TP1-introduction/Arguments.java new file mode 100644 index 0000000..d4c0fed --- /dev/null +++ b/DEV.2.1/TP/TP1-introduction/Arguments.java @@ -0,0 +1,30 @@ +public class Arguments { + public static void main(String[] args) { + + if (args.length > 0) { + System.out.println("Bonjour, " + args[0] + " !"); + + if (args.length > 1) { + System.out.println("Bonjour, " + args[1] + " !"); + + } + if (args.length > 2) { + System.out.println("Bonjour, " + args[2] + " !"); + } + + } else { + System.out.println("Aucun nom n'a été fourni !"); + } + } +} + +/* +public class Arguments { + public static void main (String[] args) { + for (String nom ': args) { + System.out.println("Bonjour, " + nom + " !"); + } + } +} + AVEC UNE BOUCLE for +*/ \ No newline at end of file diff --git a/DEV.2.1/TP/TP1-introduction/Grille.class b/DEV.2.1/TP/TP1-introduction/Grille.class new file mode 100644 index 0000000..a55d833 Binary files /dev/null and b/DEV.2.1/TP/TP1-introduction/Grille.class differ diff --git a/DEV.2.1/TP/TP1-introduction/Grille.java b/DEV.2.1/TP/TP1-introduction/Grille.java new file mode 100644 index 0000000..7ffe7fa --- /dev/null +++ b/DEV.2.1/TP/TP1-introduction/Grille.java @@ -0,0 +1,31 @@ +public class Grille { + public static void main(String[] args) { + // Vérification de la validité de l'argument + if (args.length == 0 || Integer.parseInt(args[0]) <= 0) { + System.out.println("Pas de tableau"); + } else { + int taille = Integer.parseInt(args[0]); + + // Construction de la grille + for (int i = 0; i < taille; i++) { + // Ligne horizontale + for (int j = 0; j < taille; j++) { + System.out.print("+-"); + } + System.out.println("+"); + + // Ligne verticale + for (int j = 0; j < taille; j++) { + System.out.print("| "); + } + System.out.println("|"); + } + + // Dernière ligne horizontale + for (int j = 0; j < taille; j++) { + System.out.print("+-"); + } + System.out.println("+"); + } + } +} diff --git a/DEV.2.1/TP/TP1-introduction/Somme.java b/DEV.2.1/TP/TP1-introduction/Somme.java new file mode 100644 index 0000000..17e2280 --- /dev/null +++ b/DEV.2.1/TP/TP1-introduction/Somme.java @@ -0,0 +1,7 @@ +public class Somme { + public static void main(String[] args) { + int somme = Integer.parseInt(args[0]) + Integer.parseInt(args[1]); + + System.out.println("La somme des nombres est : " + somme); + } +} \ No newline at end of file diff --git a/DEV.2.1/TP/TP1-introduction/Tri.class b/DEV.2.1/TP/TP1-introduction/Tri.class new file mode 100644 index 0000000..28aa04e Binary files /dev/null and b/DEV.2.1/TP/TP1-introduction/Tri.class differ diff --git a/DEV.2.1/TP/TP1-introduction/Tri.java b/DEV.2.1/TP/TP1-introduction/Tri.java new file mode 100644 index 0000000..b18be73 --- /dev/null +++ b/DEV.2.1/TP/TP1-introduction/Tri.java @@ -0,0 +1,20 @@ +import java.util.Arrays; + +public class Tri { + public static void main(String[] args) { + if (args.length == 0) { + System.out.println("Veuillez fournir des nombres en arguments."); + return; + } + + int[] nombres = new int[args.length]; + + for(int i = 0; i