diff --git a/Anglish/16102023.docx b/Anglish/16102023.docx new file mode 100755 index 0000000..679128b Binary files /dev/null and b/Anglish/16102023.docx differ diff --git a/DEV/DEV3.2/TP02_Recursivite/Q5Main.class b/DEV/DEV3.2/TP02_Recursivite/Q5Main.class index e4f781a..b2ca7b3 100644 Binary files a/DEV/DEV3.2/TP02_Recursivite/Q5Main.class and b/DEV/DEV3.2/TP02_Recursivite/Q5Main.class differ diff --git a/DEV/DEV3.2/TP02_Recursivite/Q5Main.java b/DEV/DEV3.2/TP02_Recursivite/Q5Main.java index 9e3c9a1..ff15572 100644 --- a/DEV/DEV3.2/TP02_Recursivite/Q5Main.java +++ b/DEV/DEV3.2/TP02_Recursivite/Q5Main.java @@ -2,23 +2,29 @@ import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.awt.Polygon; +import java.lang.Math; public class Q5Main{ public static void main(String[] args) { - + int l = 1000; + int m = 40; + int detail = Integer.parseInt(args[0]); JFrame fenetre = new JFrame("Q1 Galerie"); - fenetre.setSize(300, 200); - fenetre.setLocation(700, 300); + fenetre.setSize(l+2*m, l+2*m); + fenetre.setLocation(0, 0); fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Polygon etoile = new Polygon(); - etoile.addPoint(50,50); - etoile.addPoint(300,140); - etoile.addPoint(230,80); - etoile.addPoint(10,330); - fenetre.setVisible(true); - Q5Polygon dessinEtoile = new Q5Polygon(etoile); + Q5Recursivite modele = new Q5Recursivite(etoile, fenetre); fenetre.add(dessinEtoile); + fenetre.setVisible(true); + + Q5Point g = new Q5Point(m+l/2, m); + Q5Point c = new Q5Point(m+l-((int)(l*Math.sqrt(3))/2), m+(3*l)/4); + Q5Point a = new Q5Point(2*m+((int)(l*Math.sqrt(3))/2), m+(3*l)/4); + modele.nextStep(detail, a,c,g); + modele.nextStep(detail, c,g,a); + modele.nextStep(detail, g,a,c); } } \ No newline at end of file diff --git a/DEV/DEV3.2/TP02_Recursivite/Q5Point.class b/DEV/DEV3.2/TP02_Recursivite/Q5Point.class new file mode 100644 index 0000000..ff9a202 Binary files /dev/null and b/DEV/DEV3.2/TP02_Recursivite/Q5Point.class differ diff --git a/DEV/DEV3.2/TP02_Recursivite/Q5Point.java b/DEV/DEV3.2/TP02_Recursivite/Q5Point.java new file mode 100644 index 0000000..aab77eb --- /dev/null +++ b/DEV/DEV3.2/TP02_Recursivite/Q5Point.java @@ -0,0 +1,33 @@ +public class Q5Point{ + public int x; + public int y; + + public Q5Point(int x, int y) { + this.x = x; + this.y = y; + } + public Q5Point() { + this.x = 0; + this.y = 0; + } + + public static Q5Point tiers(Q5Point a, Q5Point b){ + Q5Point resultat = new Q5Point(); + resultat.x = (int) a.x + (b.x - a.x)/3; + resultat.y = (int) a.y + (b.y - a.y)/3; + return resultat; + } + public static Q5Point millieu(Q5Point a, Q5Point b){ + Q5Point resultat = new Q5Point(); + resultat.x = (int) a.x + (b.x - a.x)/2; + resultat.y = (int) a.y + (b.y - a.y)/2; + return resultat; + } + public static Q5Point pointe(Q5Point a, Q5Point b, Q5Point p){ + Q5Point i = Q5Point.millieu(a,b); + Q5Point resultat = new Q5Point(); + resultat.x = (int) i.x - (p.x - i.x)/3; + resultat.y = (int) i.y - (p.y - i.y)/3; + return resultat; + } +} \ No newline at end of file diff --git a/DEV/DEV3.2/TP02_Recursivite/Q5Polygon.class b/DEV/DEV3.2/TP02_Recursivite/Q5Polygon.class index 26ec157..87b4611 100644 Binary files a/DEV/DEV3.2/TP02_Recursivite/Q5Polygon.class and b/DEV/DEV3.2/TP02_Recursivite/Q5Polygon.class differ diff --git a/DEV/DEV3.2/TP02_Recursivite/Q5Polygon.java b/DEV/DEV3.2/TP02_Recursivite/Q5Polygon.java index 87a74ca..62d3c27 100644 --- a/DEV/DEV3.2/TP02_Recursivite/Q5Polygon.java +++ b/DEV/DEV3.2/TP02_Recursivite/Q5Polygon.java @@ -11,6 +11,6 @@ public class Q5Polygon extends JComponent { @Override protected void paintComponent(Graphics pinceau) { pinceau.setColor(Color.BLUE); - pinceau.fillPolygon(this.etoile); + pinceau.drawPolygon(this.etoile); } } \ No newline at end of file diff --git a/DEV/DEV3.2/TP02_Recursivite/Q5Recursivite.class b/DEV/DEV3.2/TP02_Recursivite/Q5Recursivite.class new file mode 100644 index 0000000..e9192ac Binary files /dev/null and b/DEV/DEV3.2/TP02_Recursivite/Q5Recursivite.class differ diff --git a/DEV/DEV3.2/TP02_Recursivite/Q5Recursivite.java b/DEV/DEV3.2/TP02_Recursivite/Q5Recursivite.java new file mode 100644 index 0000000..b7a0e04 --- /dev/null +++ b/DEV/DEV3.2/TP02_Recursivite/Q5Recursivite.java @@ -0,0 +1,32 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.awt.Polygon; + +public class Q5Recursivite{ + public Polygon etoile; + public JFrame fenetre; + + public Q5Recursivite(Polygon etoile, JFrame fenetre) { + this.etoile = etoile; + this.fenetre = fenetre; + } + public void nextStep(int i, Q5Point c, Q5Point g, Q5Point a){ + if (i<=0){ + this.etoile.addPoint(c.x,c.y); + this.fenetre.repaint(); + } + else{ + Q5Point b = Q5Point.tiers(c,a); + Q5Point d = Q5Point.tiers(c,g); + Q5Point e = Q5Point.pointe(c,g,a); + Q5Point f = Q5Point.tiers(g,c); + Q5Point h = Q5Point.tiers(g,a); + this.nextStep(i-1, c, d, b); + this.nextStep(i-1, d, e, f); + this.nextStep(i-1, e, f, d); + this.nextStep(i-1, f, g, h); + } + + } +} \ No newline at end of file diff --git a/DEV/DEV3.2/TP03_Listes/Action.class b/DEV/DEV3.2/TP03_Listes/Action.class new file mode 100644 index 0000000..36c7dd7 Binary files /dev/null and b/DEV/DEV3.2/TP03_Listes/Action.class differ diff --git a/DEV/DEV3.2/TP03_Listes/Action.java b/DEV/DEV3.2/TP03_Listes/Action.java new file mode 100644 index 0000000..66ec4f2 --- /dev/null +++ b/DEV/DEV3.2/TP03_Listes/Action.java @@ -0,0 +1,34 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.util.*; + +public class Action implements MouseListener{ + public java.util.List listeParallelogramme; + + public Action(java.util.List listeParallelogramme){ + this.listeParallelogramme = listeParallelogramme; + } + + @Override + public void mouseClicked(MouseEvent e){ + for (Parallelogramme parallelogramme : this.listeParallelogramme){ + if (parallelogramme.forme.contains(e.getPoint())){ + System.out.println("clic"); + } + } + } + + @Override + public void mouseEntered(MouseEvent e){ + } + @Override + public void mouseExited(MouseEvent e){ + } + @Override + public void mousePressed(MouseEvent e){ + } + @Override + public void mouseReleased(MouseEvent e){ + } +} diff --git a/DEV/DEV3.2/TP03_Listes/Dessin.class b/DEV/DEV3.2/TP03_Listes/Dessin.class new file mode 100644 index 0000000..c2225be Binary files /dev/null and b/DEV/DEV3.2/TP03_Listes/Dessin.class differ diff --git a/DEV/DEV3.2/TP03_Listes/Dessin.java b/DEV/DEV3.2/TP03_Listes/Dessin.java new file mode 100644 index 0000000..05031c5 --- /dev/null +++ b/DEV/DEV3.2/TP03_Listes/Dessin.java @@ -0,0 +1,27 @@ +import javax.swing.JComponent; +import java.awt.*; +import java.util.*; + +public class Dessin extends JComponent { + + public java.util.List listeParallelogramme; + + public Dessin(java.util.List listeParallelogramme){ + this.listeParallelogramme = listeParallelogramme; + } + + @Override + protected void paintComponent(Graphics pinceau) { + Graphics secondPinceau = pinceau.create(); + if (this.isOpaque()) { + secondPinceau.setColor(this.getBackground()); + secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight()); + } + for (Parallelogramme parallelogramme : this.listeParallelogramme){ + secondPinceau.setColor(parallelogramme.couleur); + secondPinceau.fillPolygon(parallelogramme.forme); + secondPinceau.setColor(Color.BLACK); + secondPinceau.drawPolygon(parallelogramme.forme); + } + } +} diff --git a/DEV/DEV3.2/TP03_Listes/Main.class b/DEV/DEV3.2/TP03_Listes/Main.class new file mode 100644 index 0000000..44eb60d Binary files /dev/null and b/DEV/DEV3.2/TP03_Listes/Main.class differ diff --git a/DEV/DEV3.2/TP03_Listes/Main.java b/DEV/DEV3.2/TP03_Listes/Main.java new file mode 100644 index 0000000..7c34d8e --- /dev/null +++ b/DEV/DEV3.2/TP03_Listes/Main.java @@ -0,0 +1,28 @@ +import javax.swing.*; +import java.awt.*; +import java.util.*; + +public class Main{ + public static void main(String[] args){ + JFrame fenetre = new JFrame(); + fenetre.setSize(700, 300); + fenetre.setLocation(0, 0); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + java.util.List listeParallelogramme = new ArrayList<>(); + int i; + Parallelogramme suivant = new Parallelogramme(); + for (i=0; i<10; i++){ + listeParallelogramme.add(suivant); + suivant = new Parallelogramme(suivant); + } + + Action action = new Action(listeParallelogramme); + fenetre.addMouseListener(action); + + Dessin lesDessins = new Dessin(listeParallelogramme); + fenetre.add(lesDessins); + + fenetre.setVisible(true); + } +} diff --git a/DEV/DEV3.2/TP03_Listes/Parallelogramme.class b/DEV/DEV3.2/TP03_Listes/Parallelogramme.class new file mode 100644 index 0000000..a08a8d6 Binary files /dev/null and b/DEV/DEV3.2/TP03_Listes/Parallelogramme.class differ diff --git a/DEV/DEV3.2/TP03_Listes/Parallelogramme.java b/DEV/DEV3.2/TP03_Listes/Parallelogramme.java new file mode 100644 index 0000000..cc36c8b --- /dev/null +++ b/DEV/DEV3.2/TP03_Listes/Parallelogramme.java @@ -0,0 +1,28 @@ +import java.awt.*; +import java.util.*; + +public class Parallelogramme{ + public static int hauteur=100; + public static int largeur=50; + public static int marge=5; + public static int inclinaison=40; + public static Random aleatoire = new Random(); + + public Polygon forme; + public Color couleur; + + public Parallelogramme(){ + this(0,Parallelogramme.marge); + } + public Parallelogramme(Parallelogramme ancien){ + this(ancien.forme.xpoints[1],ancien.forme.ypoints[2]); + } + public Parallelogramme(int gauche, int haut){ + this.forme = new Polygon(); + this.couleur = new Color(Parallelogramme.aleatoire.nextInt(255), Parallelogramme.aleatoire.nextInt(255), Parallelogramme.aleatoire.nextInt(255)); + this.forme.addPoint(gauche+Parallelogramme.marge, haut+Parallelogramme.hauteur); + this.forme.addPoint(gauche+Parallelogramme.marge+Parallelogramme.largeur, haut+Parallelogramme.hauteur); + this.forme.addPoint(gauche+Parallelogramme.marge+Parallelogramme.largeur+Parallelogramme.inclinaison, haut); + this.forme.addPoint(gauche+Parallelogramme.marge+Parallelogramme.inclinaison, haut); + } +} \ No newline at end of file diff --git a/DEV/DEV_Madelaine/TD1/ex1.txt b/DEV/DEV_Madelaine/TD1/ex1.txt new file mode 100644 index 0000000..3753df8 --- /dev/null +++ b/DEV/DEV_Madelaine/TD1/ex1.txt @@ -0,0 +1,16 @@ +1. +employee + +2. +employee + +3. +gerer la bibliotheque (gerer les adherants, gerer les oeuvres) +gerer les contentieux +s'authentifier +lancer des poursuites judiciaires + +4. + + +5. diff --git a/DEV/DEV_William/TP01_2.ods b/DEV/DEV_William/TP01_2.ods index d2e65d5..5cf25c6 100644 Binary files a/DEV/DEV_William/TP01_2.ods and b/DEV/DEV_William/TP01_2.ods differ diff --git a/SCR/TP05/ex1.1.c b/SCR/TP05/ex1.1.c new file mode 100644 index 0000000..46b76f6 --- /dev/null +++ b/SCR/TP05/ex1.1.c @@ -0,0 +1,20 @@ +#define _GNU_SOURCE +#include +#include +#include +#include +#include + + +int main(int argc, char *argv[]) +{ + int t[2]; + int size; + + assert(pipe(t) == 0); + + size = fcntl(t[0],F_GETPIPE_SZ); + + printf("size = %d\n",size); + return 0; +} diff --git a/SCR/TP05/ex1.2.c b/SCR/TP05/ex1.2.c new file mode 100644 index 0000000..c7d04ea --- /dev/null +++ b/SCR/TP05/ex1.2.c @@ -0,0 +1,24 @@ +#define _GNU_SOURCE +#include +#include +#include +#include +#include + +// ls -i -l /tmp >> log +// +int main(int argc, char *argv[]) +{ + + + int redirection = open("./log",O_WRONLY | O_APPEND | O_CREAT , 0644); + + assert(redirection >= 0); + // dup2 ferme 1, et duplique redirection + dup2(redirection,1); + close(redirection); + + execlp("ls","ls","-i","-l","/tmp",NULL); + assert(0); + return 0; +} diff --git a/SCR/TP05/prime.c b/SCR/TP05/prime.c new file mode 100644 index 0000000..b5075e2 --- /dev/null +++ b/SCR/TP05/prime.c @@ -0,0 +1,76 @@ +#include +#include +#include +#include +void filter(int p) +{ + while(1){ + int n; + ssize_t nb_read = read(0,&n,sizeof(int)); + if (nb_read <= 0) + break; + if ((n%p)!=0) + write(1,&n,sizeof(int)); + } +} + +void seq(int n) +{ + for (int i = 2; i <=n; i++) + write(1,&i,sizeof(int)); +} + +void chef(void) +{ + while(1){ + int p; + pid_t f; + int t[2]; + ssize_t nb_read = read(0,&p,sizeof(int)); + if (nb_read <= 0) + break; + + printf("new prime %d\n",p); + pipe(t); + f = fork(); + if (f == 0){ + close(t[0]); + dup2(t[1],1); + close(t[1]); + filter(p); + exit(0); + } + close(t[1]); + dup2(t[0],0); + close(t[0]); + } +} + +int main(int argc, char *argv[]) +{ + pid_t p; + struct sigaction sa = {0}; + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_NOCLDWAIT; + sigaction(SIGCHLD,&sa,NULL); + int t[2]; + int N = strtol(argv[1],NULL,0); + + pipe(t); + p = fork(); + + if (p == 0){ + close(t[0]); + dup2(t[1],1); + close(t[1]); + seq(N); + exit(0); + } + close(t[1]); + dup2(t[0],0); + close(t[0]); + chef(); + return 0; +} + + diff --git a/SCR/TP06/ex2.c b/SCR/TP06/ex2.c index 8c254f4..5af9ba0 100644 --- a/SCR/TP06/ex2.c +++ b/SCR/TP06/ex2.c @@ -2,62 +2,102 @@ #include #include #include +#include + +#define ELIMINE -1 typedef struct duel{ - int participant1; - int participant2; + int* liste; + int debut; + int tailleGroupe; } duel; -void *tournois(void *thread_id) { - int id = *((int *) thread_id); - printf("Hello from thread %d\n", id); +void affichage(int* liste, int capacite){ + int i; + for(i=0; i participant1){ + return debut + indiceParticipant1; + } + else{ + return debut + i; + } + } + } + } + return -1; +} + +void *tournois(void *argument) { + duel duo = *((duel*) argument); + int i; + int perdant = plusPetit(duo.liste, duo.debut, duo.tailleGroupe); + duo.liste[perdant] = -1; return NULL; } int puissance2(int n){ - for (int p=1; pnom = argv[i]; - participant->id = i; - } - while (nbDuel > 1){ - for (int i = 0; i < nbDuel; i++){ - duel[nbDuel] tabDuel; - participant participant2; - for (int x=0, y=0, ) - participant duel[] = {participant[i], participant[i+1]}; - assert( pthread_create(&threads[i], NULL, tournois, &participant[i]) == 0); + while (nbDuel>=1){ + pthread_t threads[nbDuel]; + duel argument[nbDuel]; + int i; + for (i=0; i +#include +#include +#include +#include + +typedef struct structure{ + int debut; + int fin; + int saut; + int* resultat; +} structure; + +static inline double tstamp(void) +{ + struct timespec tv; + clock_gettime(CLOCK_REALTIME, &tv); + return tv.tv_sec + tv.tv_nsec * 1.0e-9; +} + + +void *somme(void *argument) { + structure data = *((structure *) argument); + for (; data.debut<=data.fin; data.debut += data.saut){ + *data.resultat += data.debut; + } + return NULL; +} + +int main(int argc, char* argv[]) { + assert(argc-1 == 2); + int limite = (int) strtol(argv[1], NULL, 0); + int nbThread = (int) strtol(argv[2], NULL, 0); + int sommeFinal = 0; + double startTime, endTime; + int resultatThread[nbThread]; + pthread_t threads[nbThread]; + structure argument[nbThread]; + + for (int i = 0; i < nbThread; i++){ + argument[i].debut = i; + argument[i].fin = limite; + argument[i].saut = nbThread; + resultatThread[i] = 0; + argument[i].resultat = &resultatThread[i]; + } + startTime = tstamp(); + for (int i = 0; i < nbThread; i++){ + assert( pthread_create(&threads[i], NULL, somme, &argument[i]) == 0); + } + + for (int i = 0; i < nbThread; i++){ + assert( pthread_join(threads[i], NULL) == 0); + sommeFinal += *argument[i].resultat; + } + endTime = tstamp(); + printf("somme : %d\ntemps : %lf\n", sommeFinal, endTime-startTime); + + return EXIT_SUCCESS; +} diff --git a/SCR/TP06/exe b/SCR/TP06/exe new file mode 100755 index 0000000..f4ed895 Binary files /dev/null and b/SCR/TP06/exe differ diff --git a/test b/test new file mode 100644 index 0000000..e69de29