This commit is contained in:
Adrian POURCHOT 2024-11-27 11:35:15 +01:00
parent 467af38a01
commit d39124f928
21 changed files with 902 additions and 56 deletions

View File

@ -1,4 +1,4 @@
import java.awt.Graphics;
0import java.awt.Graphics;
import java.awt.Color;
import javax.swing.*;
import java.awt.event.*;

Binary file not shown.

View File

@ -1,55 +1,61 @@
import java.util.*;
public class Main{
public class Main {
public static ArrayDeque<Float> scinder(ArrayDeque<Float> file){
ArrayDeque<Float> nouveaufile = new ArrayDeque(file.size()/2);
public static ArrayDeque<Float> scinder(ArrayDeque<Float> file) {
ArrayDeque<Float> nouveaufile = new ArrayDeque<>();
for (int i=0; i<(file.size()/2); i++){
for (int i = 0; i < file.size() / 2; i++) {
nouveaufile.add(file.poll());
}
return nouveaufile;
}
public static ArrayDeque<Float> fusionner(ArrayDeque<Float> fileun, ArrayDeque<Float> filedeux){
public static ArrayDeque<Float> fusionner(ArrayDeque<Float> fileun, ArrayDeque<Float> filedeux) {
ArrayDeque<Float> fusionnee = new ArrayDeque<>();
for (int i=0; i<(filedeux.size()); i++){
fileun.add(filedeux.poll());
while (!fileun.isEmpty() && !filedeux.isEmpty()) {
if (fileun.peek() <= filedeux.peek()) {
fusionnee.add(fileun.poll());
} else {
fusionnee.add(filedeux.poll());
}
}
return fileun;
fusionnee.addAll(fileun);
fusionnee.addAll(filedeux);
return fusionnee;
}
public static ArrayDeque<Float> trier(ArrayDeque<Float> file){
switch (file.size()){
case 1:
public static ArrayDeque<Float> trier(ArrayDeque<Float> file) {
if (file.size() <= 1) {
return file;
case 2:
if (file.getFirst()>file.getLast()){
file.add(file.poll());
}
return file;
default:
ArrayDeque<Float> nouveaufile = new ArrayDeque(file.size()/2);
nouveaufile=scinder(file);
return fusionner(trier(nouveaufile),trier(file));
}
ArrayDeque<Float> fileun = scinder(file);
ArrayDeque<Float> filedeux = new ArrayDeque<>(file);
filedeux.removeAll(fileun);
fileun = trier(fileun);
filedeux = trier(filedeux);
return fusionner(fileun, filedeux);
}
public static void main(String[] args) {
ArrayDeque<Float> file = new ArrayDeque(args.length);
ArrayDeque<Float> file = new ArrayDeque<>();
for (int i=0; i<args.length; i++){
file.add(Float.parseFloat(args[i]));
for (String arg : args) {
file.add(Float.parseFloat(arg));
}
file=trier(file);
file = trier(file);
for (int i=0; i<args.length; i++){
System.out.println(""+file.poll()+"\n");
for (Float f : file) {
System.out.println(f);
}
}
}

752
DEV3.2/TP6/Couleurs/rgb.txt Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -2,11 +2,21 @@ import java.util.*;
public class Main {
public static void main (String[] args){
Map<Thread,StackTraceElement[]> dico =Thread.getAllStackTraces();
Set<Map.Entry<Thread,StackTraceElement[]>> tab=dico.entrySet();
Iterator ite=tab.iterator();
for (;ite.hasNext();){
System.out.println(ite.next()+"\n");
Map<Thread, StackTraceElement[]> dico = Thread.getAllStackTraces();
Set<Map.Entry<Thread, StackTraceElement[]>> tab = dico.entrySet();
Iterator<Map.Entry<Thread, StackTraceElement[]>> ite = tab.iterator();
for (; ite.hasNext(); ) {
Map.Entry<Thread, StackTraceElement[]> entry = ite.next();
Thread thread = entry.getKey();
StackTraceElement[] stackTrace = entry.getValue();
System.out.println(thread.getName() + " :");
for (StackTraceElement element : stackTrace) {
System.out.println(" " + element);
}
System.out.println();
}
}
}

Binary file not shown.

View File

@ -0,0 +1,25 @@
import java.util.*;
public class Main {
protected static ArrayDeque<String> pile;
public static void main(String[] args) {
Main.pile = new ArrayDeque(args.length);
for (int i=0; i<args.length; i++){
Main.pile.push(args[i]);
}
Noeud noeudDeb;
String debutArbre = Main.pile.pop();
if (debutArbre.equals("+")||debutArbre.equals("-")||debutArbre.equals("x")||debutArbre.equals("/")){
noeudDeb = new NoeudOperation(debutArbre);
}
else{
noeudDeb = new NoeudChiffre(debutArbre);
}
noeudDeb.afficherNoeud();
System.out.print("\n");
}
}

Binary file not shown.

View File

@ -0,0 +1,8 @@
public class Noeud{
protected String val;
protected Noeud noeudGauche;
protected Noeud noeudDroit;
protected void afficherNoeud(){
}
}

Binary file not shown.

View File

@ -0,0 +1,11 @@
public class NoeudChiffre extends Noeud{
public NoeudChiffre(String n){
this.val = n;
}
protected void afficherNoeud(){
System.out.print(val);
}
}

Binary file not shown.

View File

@ -0,0 +1,28 @@
public class NoeudOperation extends Noeud{
public NoeudOperation(String ope){
this.val = ope;
String prochainNoeud = Main.pile.pop();
if (prochainNoeud.equals("+")||prochainNoeud.equals("-")||prochainNoeud.equals("x")||prochainNoeud.equals("/")){
this.noeudGauche = new NoeudOperation(prochainNoeud);
}
else{
this.noeudGauche = new NoeudChiffre(prochainNoeud);
}
String prochainNoeud2 = Main.pile.pop();
if (prochainNoeud2.equals("+")||prochainNoeud2.equals("-")||prochainNoeud2.equals("x")||prochainNoeud2.equals("/")){
this.noeudDroit = new NoeudOperation(prochainNoeud2);
}
else{
this.noeudDroit = new NoeudChiffre(prochainNoeud2);
}
}
protected void afficherNoeud(){
System.out.print('(');
this.noeudDroit.afficherNoeud();
System.out.print(val);
this.noeudGauche.afficherNoeud();
System.out.print(')');
}
}

Binary file not shown.

View File

@ -20,5 +20,6 @@ public class Main {
noeudDeb = new NoeudChiffre(debutArbre);
}
noeudDeb.afficherNoeud();
System.out.print("\n");
}
}

Binary file not shown.

View File

@ -2,7 +2,6 @@ public class NoeudOperation extends Noeud{
public NoeudOperation(String ope){
this.val = ope;
for(int i=0;i<2;i++){
String prochainNoeud = Main.pile.pop();
if (prochainNoeud.equals("+")||prochainNoeud.equals("-")||prochainNoeud.equals("x")||prochainNoeud.equals("/")){
this.noeudGauche = new NoeudOperation(prochainNoeud);
@ -10,12 +9,18 @@ public class NoeudOperation extends Noeud{
else{
this.noeudGauche = new NoeudChiffre(prochainNoeud);
}
String prochainNoeud2 = Main.pile.pop();
if (prochainNoeud2.equals("+")||prochainNoeud2.equals("-")||prochainNoeud2.equals("x")||prochainNoeud2.equals("/")){
this.noeudDroit = new NoeudOperation(prochainNoeud2);
}
else{
this.noeudDroit = new NoeudChiffre(prochainNoeud2);
}
}
protected void afficherNoeud(){
System.out.print(val+" ");
this.noeudGauche.afficherNoeud();
this.noeudDroit.afficherNoeud();
this.noeudGauche.afficherNoeud();
}
}