TP
This commit is contained in:
parent
467af38a01
commit
d39124f928
@ -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.
Binary file not shown.
@ -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++){
|
||||
nouveaufile.add(file.poll());
|
||||
}
|
||||
for (int i = 0; i < file.size() / 2; i++) {
|
||||
nouveaufile.add(file.poll());
|
||||
}
|
||||
|
||||
return nouveaufile;
|
||||
}
|
||||
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);
|
||||
|
||||
public static ArrayDeque<Float> trier(ArrayDeque<Float> file){
|
||||
switch (file.size()){
|
||||
case 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));
|
||||
return fusionnee;
|
||||
}
|
||||
|
||||
}
|
||||
public static ArrayDeque<Float> trier(ArrayDeque<Float> file) {
|
||||
if (file.size() <= 1) {
|
||||
return file;
|
||||
}
|
||||
|
||||
}
|
||||
ArrayDeque<Float> fileun = scinder(file);
|
||||
ArrayDeque<Float> filedeux = new ArrayDeque<>(file);
|
||||
|
||||
public static void main(String[] args) {
|
||||
ArrayDeque<Float> file = new ArrayDeque(args.length);
|
||||
filedeux.removeAll(fileun);
|
||||
|
||||
for (int i=0; i<args.length; i++){
|
||||
file.add(Float.parseFloat(args[i]));
|
||||
}
|
||||
fileun = trier(fileun);
|
||||
filedeux = trier(filedeux);
|
||||
|
||||
file=trier(file);
|
||||
return fusionner(fileun, filedeux);
|
||||
}
|
||||
|
||||
for (int i=0; i<args.length; i++){
|
||||
System.out.println(""+file.poll()+"\n");
|
||||
}
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
ArrayDeque<Float> file = new ArrayDeque<>();
|
||||
|
||||
for (String arg : args) {
|
||||
file.add(Float.parseFloat(arg));
|
||||
}
|
||||
|
||||
file = trier(file);
|
||||
|
||||
for (Float f : file) {
|
||||
System.out.println(f);
|
||||
}
|
||||
}
|
||||
}
|
752
DEV3.2/TP6/Couleurs/rgb.txt
Normal file
752
DEV3.2/TP6/Couleurs/rgb.txt
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
BIN
DEV3.2/TP7/Infixe/Main.class
Normal file
BIN
DEV3.2/TP7/Infixe/Main.class
Normal file
Binary file not shown.
25
DEV3.2/TP7/Infixe/Main.java
Normal file
25
DEV3.2/TP7/Infixe/Main.java
Normal 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");
|
||||
}
|
||||
}
|
BIN
DEV3.2/TP7/Infixe/Noeud.class
Normal file
BIN
DEV3.2/TP7/Infixe/Noeud.class
Normal file
Binary file not shown.
8
DEV3.2/TP7/Infixe/Noeud.java
Normal file
8
DEV3.2/TP7/Infixe/Noeud.java
Normal file
@ -0,0 +1,8 @@
|
||||
public class Noeud{
|
||||
protected String val;
|
||||
protected Noeud noeudGauche;
|
||||
protected Noeud noeudDroit;
|
||||
|
||||
protected void afficherNoeud(){
|
||||
}
|
||||
}
|
BIN
DEV3.2/TP7/Infixe/NoeudChiffre.class
Normal file
BIN
DEV3.2/TP7/Infixe/NoeudChiffre.class
Normal file
Binary file not shown.
11
DEV3.2/TP7/Infixe/NoeudChiffre.java
Normal file
11
DEV3.2/TP7/Infixe/NoeudChiffre.java
Normal file
@ -0,0 +1,11 @@
|
||||
public class NoeudChiffre extends Noeud{
|
||||
|
||||
public NoeudChiffre(String n){
|
||||
this.val = n;
|
||||
}
|
||||
|
||||
protected void afficherNoeud(){
|
||||
System.out.print(val);
|
||||
}
|
||||
|
||||
}
|
BIN
DEV3.2/TP7/Infixe/NoeudOperation.class
Normal file
BIN
DEV3.2/TP7/Infixe/NoeudOperation.class
Normal file
Binary file not shown.
28
DEV3.2/TP7/Infixe/NoeudOperation.java
Normal file
28
DEV3.2/TP7/Infixe/NoeudOperation.java
Normal 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.
@ -20,5 +20,6 @@ public class Main {
|
||||
noeudDeb = new NoeudChiffre(debutArbre);
|
||||
}
|
||||
noeudDeb.afficherNoeud();
|
||||
System.out.print("\n");
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,20 +2,25 @@ 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);
|
||||
}
|
||||
else{
|
||||
this.noeudGauche = new NoeudChiffre(prochainNoeud);
|
||||
}
|
||||
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(val+" ");
|
||||
this.noeudGauche.afficherNoeud();
|
||||
this.noeudDroit.afficherNoeud();
|
||||
this.noeudGauche.afficherNoeud();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user