This commit is contained in:
EmmanuelTiamzon
2025-09-30 09:43:41 +02:00
parent f7de13bc2a
commit 7019a3b7ea
176 changed files with 9458 additions and 149 deletions

View File

@@ -1,17 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char *argv[]) {
long int x, y;
ldiv_t result;
sscanf(argv[1], "%ld", &x);
sscanf(argv[2], "%ld", &y);
result = ldiv(x, y);
printf("quotient : %ld\n", result.quot);
printf("reste : %ld\n", result.rem);
return EXIT_SUCCESS;
}

View File

@@ -0,0 +1,16 @@
#include <stdlib.h>
#include <stdio.h>
int somme(int n, int m) {
return n+m;
}
int main(void) {
int valeur;
int* p = NULL;
printf("Entrez un entier : ");
scanf("%d", p);
printf("Le double vaut %d\n", somme(*p, *p));
return EXIT_SUCCESS;
}

View File

@@ -1,6 +1,14 @@
#include <stdio.h>
#include <stdlib.h>
typedef struct {
char tab[50];
int indice_debut;
int indice_fin;
int taille;
} pile;
struct maillon_s {
char valeurs;
struct maillon_s* suivant;

View File

@@ -1,27 +1,43 @@
public class Configuration {
private char[9] grille;
private char[] grille;
/*
On veut que chaque case soit un x ou un o et que si elle est vide alors n
la première case est 1 la deuxième 2, etc...
*/
public Configuration() {
this.grille = {'n','n','n','n','n','n','n','n','n'};
this.grille = new char[]{'n','n','n','n','n','n','n','n','n'};
}
public static int estLibre(int posGrille) {
if(this.grille[posGrille-1] == 'n') {
return true;
}
public boolean estLibre(int posGrille) {
if (posGrille < 1 || posGrille > 9) {
throw new IllegalArgumentException("La position doit être entre 1 et 9.");
}
return this.grille[posGrille - 1] == 'n';
}
public void jouer(int position, char joueur) {
if(joueur == 'x') {
this.grille[position-1] = 'x';
} else if(joueur == 'o') {
this.grille[position-1] = 'o';
}
}
if (position < 1 || position > 9) {
throw new IllegalArgumentException("La position doit être entre 1 et 9.");
}
if (joueur != 'x' && joueur != 'o') {
throw new IllegalArgumentException("Le joueur doit être 'x' ou 'o'.");
}
if (!estLibre(position)) {
throw new IllegalArgumentException("Cette case est déjà occupée.");
}
this.grille[position - 1] = joueur;
}
public void afficherGrille() {
for (int i = 0; i < 9; i++) {
System.out.print(this.grille[i] + " ");
if ((i + 1) % 3 == 0) {
System.out.println();
}
}
}
}

View File

@@ -0,0 +1,38 @@
public class Main {
public static void main(String[] args) {
Configuration jeu = new Configuration();
// Affichage de la grille initiale
jeu.afficherGrille();
System.out.println();
// Test de estLibre
System.out.println("Case 1 libre ? " + jeu.estLibre(1)); // true
// Test de jouer
jeu.jouer(1, 'x');
jeu.afficherGrille();
System.out.println("Case 1 libre ? " + jeu.estLibre(1)); // false
// Test de jouer sur une case occupée
try {
jeu.jouer(1, 'o'); // Doit lever une exception
} catch (Exception e) {
System.out.println(e.getMessage());
}
// Test de jouer avec une position invalide
try {
jeu.jouer(10, 'x'); // Doit lever une exception
} catch (Exception e) {
System.out.println(e.getMessage());
}
// Test de jouer avec un mauvais symbole
try {
jeu.jouer(2, 'z'); // Doit lever une exception
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}

View File

@@ -3,10 +3,11 @@ import java.awt.*;
public class Declinaisons extends JComponent {
public Declinaisons(String form, String fond) {
if(inst % 2 == 0) {
secondPinceau.setColor("")
}
private Color couleurTri;
public Declinaisons(Color couleurTri) {
super();
this.couleurTri = couleurTri;
}
@Override

View File

@@ -8,6 +8,16 @@ public class Fenetre extends JFrame {
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(500,500);
this.setLocation(500,250);
JPanel[] panneaux = {new JPanel(), new JPanel(), new JPanel(), new JPanel()};
Color[] couleursTriangles = {Color.MAGENTA, Color.YELLOW, Color.CYAN, Color.BLUE};
Color[] couleursFonds = {Color.CYAN, Color.PINK, Color.MAGENTA, Color.YELLOW};
for (int i = 0; i != 4; i++) {
panneaux[i].setBackground(couleursFonds[i]);
panneaux[i].setLayout(new BorderLayout());
panneaux[i].add(new Declinaisons(couleursTriangles[i]), BorderLayout.CENTER);
fenetre.add(panneaux[i]);
}
}
}

View File

@@ -0,0 +1,21 @@
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Acharnement extends WindowAdapter{
private int compteur;
public Acharnement() {
this.compteur = 0;
}
@Override
public void windowClosing(WindowEvent evenement) {
if (this.compteur == 2) {
System.exit(0);
}
else {
this.compteur++;
}
}
}

View File

@@ -0,0 +1,14 @@
import java.awt.*;
import javax.swing.*;
public class AcharnementMain {
public static void main(String[] args) {
JFrame fenetre = new JFrame();
fenetre.setSize(300, 200);
fenetre.setLocation(100, 100);
fenetre.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
fenetre.addWindowListener(new Acharnement());
fenetre.setVisible(true);
}
}

View File

@@ -1,11 +0,0 @@
import java.util.Arrays;
public class Duplication {
public static void main(String[] args) {
double[] tableau = new double[10];
Arrays.fill(tableau, 5.8);
System.out.println(Arrays.toString(tableau));
}
}

View File

@@ -0,0 +1,22 @@
/*Emmanuel SRIVASTAVA-TIAMZON*/
public class Filtre {
private String[] chaine;
private String[] newChaine;
public Filtre(String[] chaine) {
this.chaine = chaine;
}
public String filtrage(String[] chaine) {
for(int i = 0;i != this.chaine.length(); i++) {
if(chaine[i].isLowerCase()) {
this.newChaine += chaine[i];
}
}
return this.newChaine;
}
}

View File

@@ -0,0 +1,13 @@
/*Emmanuel SRIVASTAVA-TIAMZON*/
public class FiltreII {
public static void main(String[] args) {
for(int i = 0;i != args.length(); i++) {
if(args[i].isLowerCase() || é || è || à || ù || ç){
System.out.print(args[i]);
}
if (args[i].isWhitespace()) {
System.out.println("");
}
}
}

View File

@@ -0,0 +1,16 @@
/*Emmanuel SRIVASTAVA-TIAMZON*/
public class Excquis {
private String[] tab;
public Excquis(String[] tab) {
this.tab = tab;
}
public String toString(String[] randomTab) {
indiceRandom = nextInt(this.tab.length());
for(this.tab[indiceRandom] :
}
}

View File

@@ -0,0 +1,7 @@
/*Emmanuel SRIVASTAVA-TIAMZON*/
public class Main {
public static void main(String[] args) {
Excquis phraseI = new Excquis("John Mary Jack", "embrasse épouse tue", "chien voisin facteur", "le");
}
}

Binary file not shown.

View File

@@ -0,0 +1,27 @@
/*Emmanuel SRIVASTAVA-TIAMZON*/
import javax.swing.*;
import java.awt.*;
public class Compteurs extends JComponent {
private Image img;
public Compteurs() {
super();
this.img = Toolkit.getDefaultToolkit().getImage("img.png");
}
@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());
}
secondPinceau.setColor(this.getForeground());
secondPinceau.drawImage(this.img, this.getWidth()/2, this.getHeight()/2, this);
}
}

Binary file not shown.

View File

@@ -0,0 +1,28 @@
/*Emmanuel SRIVASTAVA-TIAMZON*/
import java.awt.*;
import javax.swing.*;
public class Fenetre extends JFrame {
public Fenetre() {
super("Compteurs");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(500,500);
this.setLocation(500,250);
Compteurs image6 = new Compteurs();
this.add(image6);
JButton up = new JButton("up");
up.setSize(50,50);
up.setLocation(this.getWidth()/2, this.getHeight()/4);
JButton down = new JButton("down");
down.setSize(50,50);
down.setLocation(this.getWidth()/2, this.getHeight()*4);
this.add(up);
this.add(down);
}
}

BIN
DEV.2.1/CM1/ex3/Main.class Normal file

Binary file not shown.

View File

@@ -0,0 +1,8 @@
/*Emmanuel SRIVASTAVA-TIAMZON*/
public class Main {
public static void main(String[] args) {
Fenetre fenetre = new Fenetre();
fenetre.setVisible(true);
}
}

BIN
DEV.2.1/CM1/ex3/img.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -1,14 +1,19 @@
/*Emmanuel SRIVASTAVA-TIAMZON*/
import javax.swing.*;
import java.awt.*;
public class Volume extends JComponent {
private int niveau = 5;
public class Illumination extends JComponent {
public Volume() {
private int niveau;
private JPanel panel;
public Illumination(int niveau) {
super();
this.niveau = niveau;
}
public setNiveau(int newNiveau) {
public int setNiveau(int newNiveau) {
if (newNiveau < 0) {
this.niveau = 0;
} else if (newNiveau > 10) {
@@ -30,7 +35,13 @@ public class Volume extends JComponent {
secondPinceau.setColor(this.getBackground);
secondPinceau.fillRect(0,0,this.getWidth(),this.getHeight());
}
secondPinceau.setBackground(Color.BLUE);
this.panel.setBackground(Color.BLACK);
if(this.niveau >= 0) {
this.panel.setBackground(Color.WHITE);
} else {
this.panel.setBackground(Color.BLACK);
}
}
}

View File

@@ -4,13 +4,13 @@ import java.awt.*;
public class Mafenetre extends JFrame {
public Mafenetre() {
super("Volume");
super("Illumination");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(697,156);
this.setLocation(500,250);
Volume volume = new Volume();
this.add(volume);
Illumination illumination = new Illumination(5);
this.add(illumination);
}
}

View File

@@ -1,7 +1,7 @@
import javax.swing.*;
import java.awt.*;
public class MainVolume {
public class Main {
public static void main(String[] args) {
Mafenetre fenetre = new Mafenetre();
fenetre.setVisible(true);

View File

@@ -1,3 +1,5 @@
/*Emmanuel SRIVASTAVA-TIAMZON*/
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
@@ -10,7 +12,13 @@ public class MouseWheel implements MouseWheelListener {
@Override
public void mouseWheelMoved(MouseWheelEvent evenement) {
if(evenement.getWheelRotation() < 0) {
this.newNiveau(evenement);
}else {
this.newNiveau(evenement);
}
}
}

Binary file not shown.

Binary file not shown.

View File

@@ -1,6 +1,5 @@
public class MainArtihmetic {
public void main(String[] args) {
String truc = "abc";
System.out.println(Integer.parse.Int(truc));
public class MainArithmetic {
public static void main(String[] args) {
System.out.println(15/0);
}
}

View File

@@ -0,0 +1,15 @@
public class Capture {
public static int ArithmeticPB(int val) {
return val/0;
}
public static void main(String[] args) {
try {
int res = ArithmeticPB(5);
System.out.println(res);
} catch(ArithmeticException e) {
System.err.println("cannot divide by 0");
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,6 @@
public class Incomplet {
public static void main(String[] args) {
byte[] txt = {0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x0D, 0x0A};
System.out.print(new String(txt));
}
}

View File

@@ -0,0 +1,9 @@
public class Conversion {
public static double celsiusAFahrenheit(double n) {
return n*9/5+32;
}
public static double FahrenheitACelsius(double n) {
return (n-32)*5/9;
}
}

View File

@@ -0,0 +1,38 @@
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
public class Degres extends JComponent {
@Override
public void paintComponent(Graphics pinceau) {
Graphics secondPinceau = pinceau.create();
if (this.isOpaque()) {
secondPinceau.setColor(this.getBackground());
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
}
secondPinceau.setColor(Color.ORANGE);
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
JTextField celsius = new JTextField();
JTextField fahrenheit = new JTextField();
celsius.setBounds(0, 65, 160, 20);
fahrenheit.setBounds(0, 90, 160, 20);
JLabel texteCelsius = new JLabel("°C");
JLabel texteFahrenheit = new JLabel("°F");
texteCelsius.setBounds(165, 65, 20, 20);
texteFahrenheit.setBounds(165, 90, 20, 20);
celsius.getDocument().addDocumentListener(new GestionJTextField(celsius, fahrenheit, true));
fahrenheit.getDocument().addDocumentListener(new GestionJTextField(fahrenheit, celsius, false));
this.add(celsius);
this.add(fahrenheit);
this.add(texteCelsius);
this.add(texteFahrenheit);
}
}

View File

@@ -0,0 +1,46 @@
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
public class GestionJTextField implements DocumentListener {
private JTextField aConvertir;
private JTextField convertirVers;
private boolean cToF;
public GestionJTextField(JTextField aConvertir, JTextField convertirVers, boolean cToF) {
this.aConvertir = aConvertir;
this.convertirVers = convertirVers;
this.cToF = cToF;
}
public void changedUpdate(DocumentEvent e) {
}
public void insertUpdate(DocumentEvent e) {
try {
if (this.cToF) {
this.convertirVers.setText(Conversion.celsiusAFahrenheit(Double.parseDouble(this.aConvertir.getText())) + "");
}
else {
this.convertirVers.setText(Conversion.FahrenheitACelsius(Double.parseDouble(this.aConvertir.getText())) + "");
}
} catch (NumberFormatException e2) {
try {
this.convertirVers.setText("???");
} catch (IllegalStateException ee) {
}
} catch (IllegalStateException e3) {
} finally {
this.convertirVers.repaint();
}
}
public void removeUpdate(DocumentEvent e) {
}
}

View File

@@ -0,0 +1,12 @@
import java.awt.*;
import javax.swing.*;
public class Fenetre extends JFrame {
public Fenetre() {
this.setSize(768, 1024);
this.setLocation(100, 100);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new GridLayout(1, 1));
this.add(new Image());
}
}

View File

@@ -0,0 +1,19 @@
import java.awt.*;
import javax.swing.*;
import java.io.*;
public class Image extends JComponent {
@Override
public void paintComponent(Graphics pinceau) {
Graphics secondPinceau = pinceau.create();
Color couleur;
if (this.isOpaque()) {
secondPinceau.setColor(this.getBackground());
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
}
secondPinceau.drawImage(new LectureFichier().getImage(), 0, 0, this);
}
}

View File

@@ -0,0 +1,52 @@
import java.awt.*;
import java.io.*;
import java.awt.image.BufferedImage;
public class LectureFichier {
private BufferedImage image;
public LectureFichier() {
this.image = new BufferedImage(768, 1024, BufferedImage.TYPE_3BYTE_BGR);
int r;
int g;
int b;
int i = 0;
int j = 0;
Color couleur;
try {
FileInputStream fichier = new FileInputStream("couleur.bin");
while(fichier.available() >= 3) {
try {
r = fichier.read();
g = fichier.read();
b = fichier.read();
couleur = new Color(r, g, b);
this.image.setRGB(i, j, couleur.getRGB());
i++;
if (i >= 768) {
j++;
i = 0;
}
} catch (IOException e2) {
System.out.println("Erreur d'accès");
}
}
try {
fichier.close();
} catch (IOException e3) {
System.out.println("Erreur de fermeture");
}
} catch (IOException e1) {
System.out.println("Erreur d'ouverture");
}
}
public BufferedImage getImage() {
return this.image;
}
}

View File

@@ -0,0 +1,6 @@
public class Main {
public static void main(String[] args) {
Fenetre fenetre = new Fenetre();
fenetre.setVisible(true);
}
}

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,99 @@
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.awt.event.WindowListener;
import java.awt.event.WindowEvent;
import javax.swing.*;
public class FermetureFenetre implements WindowListener {
private int fenetreX;
private int fenetreY;
private JFrame fenetre;
public FermetureFenetre(JFrame fenetre) {
super();
this.fenetre = fenetre;
this.fenetreX = 300;
this.fenetreY = 200;
}
public void windowActivated(WindowEvent evenement) {
} // premier plan
public void windowClosed(WindowEvent evenement) {
}
public void windowClosing(WindowEvent evenement) {
try {
Dimension dims = this.fenetre.getSize();
FileOutputStream fichier = new FileOutputStream("windowlocation.bin");
DataOutputStream flux = new DataOutputStream(fichier);
try {
flux.writeInt((int) dims.getWidth());
flux.writeInt((int) dims.getHeight());
} catch (IOException e2){
System.out.println("Erreur d'écriture");
}
try {
flux.close();
} catch (IOException e3) {
System.out.println("Erreur de fermeture");
}
} catch (IOException e) {
System.out.println("Erreur d'ouverture");
}
} // avant fermeture
public void windowDeactivated(WindowEvent evenement) {
} // arrière-plan
public void windowDeiconified(WindowEvent evenement) {
} // restauration
public void windowIconified(WindowEvent evenement){
} // minimisation
public void windowOpened(WindowEvent evenement) {
try {
FileInputStream fichier = new FileInputStream("windowlocation.bin");
DataInputStream flux = new DataInputStream(fichier);
try {
if (flux.available() >= 8) {
this.fenetreX = flux.readInt();
this.fenetreY = flux.readInt();
this.fenetre.setSize(this.fenetreX, this.fenetreY);
}
} catch (IOException e5) {
System.out.println("Erreur de lecture");
}
try {
flux.close();
} catch (IOException e6) {
System.out.println("Erreur de fermeture");
}
} catch (IOException e4) {
System.out.println("Erreur d'ouverture");
}
}
public int getX() {
return this.fenetreX;
}
public int getY() {
return this.fenetreY;
}
}

View File

@@ -0,0 +1,46 @@
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Fond {
public static void main(String[] args) {
JFrame fenetre = new JFrame();
FermetureFenetre evenementFenetre = new FermetureFenetre(fenetre);
fenetre.addWindowListener(evenementFenetre);
fenetre.setLocation(100,100);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fenetre.setLayout(new GridLayout(1, 1));
JPanel panneau = new JPanel();
JButton bouton1 = new JButton("Cyan");
JButton bouton2 = new JButton("Magenta");
JButton bouton3 = new JButton("Jaune");
bouton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evenement) {
panneau.setBackground(Color.CYAN);
}
});
bouton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evenement) {
panneau.setBackground(Color.MAGENTA);
}
});
bouton3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evenement) {
panneau.setBackground(Color.YELLOW);
}
});
panneau.add(bouton1);
panneau.add(bouton2);
panneau.add(bouton3);
fenetre.add(panneau);
fenetre.setVisible(true);
}
}

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,108 @@
import java.awt.*;
import java.io.*;
public class EcritureFichier {
private int r;
private int g;
private int b;
private int r2;
private int g2;
private int b2;
public EcritureFichier(int r, int g, int b) {
this.r = r;
this.g = g;
this.b = b;
try {
FileOutputStream fichier = new FileOutputStream("couleur.bin");
System.out.println(r + " " + g + " " + b);
try {
for (int i = 0; i != 768; i++) {
for (int j = 0; j != 1024; j++) {
fichier.write(r);
fichier.write(g);
fichier.write(b);
}
}
} catch (IOException e2) {
System.out.println("Erreur d'écriture");
}
try {
fichier.close();
} catch (IOException e3) {
System.out.println("Erreur de fermeture");
}
} catch (IOException e) {
System.out.println("Erreur d'ouverture");
}
}
public EcritureFichier(int r, int g, int b, int r2, int g2, int b2) {
this.r = r;
this.g = g;
this.b = b;
this.r2 = r2;
this.g2 = g2;
this.b2 = b2;
try {
FileOutputStream fichier = new FileOutputStream("couleur.bin");
int choixR = r;
int choixG = g;
int choixB = b;
try {
for (int l = 0; l != 8; l++) {
for (int k = 0; k != 8; k++) {
for (int i = 0; i != 768/8; i++) {
for (int j = 0; j != 1024/8; j++) {
fichier.write(choixR);
fichier.write(choixG);
fichier.write(choixB);
}
if (choixR == r) {
choixR = r2;
choixG = g2;
choixB = b2;
}
else {
choixR = r;
choixG = g;
choixB = b;
}
}
}
if (choixR == r) {
choixR = r2;
choixG = g2;
choixB = b2;
}
else {
choixR = r;
choixG = g;
choixB = b;
}
}
} catch (IOException e2) {
System.out.println("Erreur d'écriture");
}
try {
fichier.close();
} catch (IOException e3) {
System.out.println("Erreur de fermeture");
}
} catch (IOException e) {
System.out.println("Erreur d'ouverture");
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,21 @@
public class Main {
public static void main(String[] args) {
String chaineCouleur = args[0].replaceAll("#", "");
Integer r = Integer.valueOf(Integer.parseInt(chaineCouleur.substring(0, 2), 16));
Integer g = Integer.valueOf(Integer.parseInt(chaineCouleur.substring(2, 4), 16));
Integer b = Integer.valueOf(Integer.parseInt(chaineCouleur.substring(4, 6), 16));
if (args.length == 1) {
EcritureFichier ecriture = new EcritureFichier(r, g, b);
}
else if (args.length == 2) {
String chaineCouleur2 = args[1].replaceAll("#", "");
Integer r2 = Integer.valueOf(Integer.parseInt(chaineCouleur2.substring(0, 2), 16));
Integer g2 = Integer.valueOf(Integer.parseInt(chaineCouleur2.substring(2, 4), 16));
Integer b2 = Integer.valueOf(Integer.parseInt(chaineCouleur2.substring(4, 6), 16));
System.out.println(r + "," + g + "," + b + " | " + r2 + "," + g2 + "," + b2);
EcritureFichier ecriture2 = new EcritureFichier(r, g, b, r2, g2, b2);
}
}
}

Some files were not shown because too many files have changed in this diff Show More