diff --git a/q2/cours2/Couple.java b/q2/algo/cours2/Couple.java similarity index 100% rename from q2/cours2/Couple.java rename to q2/algo/cours2/Couple.java diff --git a/q2/cours2/Division.java b/q2/algo/cours2/Division.java similarity index 100% rename from q2/cours2/Division.java rename to q2/algo/cours2/Division.java diff --git a/q2/cours3/test.java b/q2/algo/cours3/test.java similarity index 100% rename from q2/cours3/test.java rename to q2/algo/cours3/test.java diff --git a/q2/cours6/Question.java b/q2/algo/cours6/Question.java similarity index 100% rename from q2/cours6/Question.java rename to q2/algo/cours6/Question.java diff --git a/q2/cours6/Questionnaire.java b/q2/algo/cours6/Questionnaire.java similarity index 100% rename from q2/cours6/Questionnaire.java rename to q2/algo/cours6/Questionnaire.java diff --git a/q2/cours6/TestsQuestionnaire.java b/q2/algo/cours6/TestsQuestionnaire.java similarity index 100% rename from q2/cours6/TestsQuestionnaire.java rename to q2/algo/cours6/TestsQuestionnaire.java diff --git a/q2/algo/hashmap.java b/q2/algo/hashmap.java new file mode 100644 index 0000000..2603573 --- /dev/null +++ b/q2/algo/hashmap.java @@ -0,0 +1,48 @@ +public class hashmap implements Map{ + + public static final TAB_SIZE = 1024; + Object[] values = new Object[TAB_SIZE]; + class tuple{ public Object key, values; + public tuple(Object key, Object value){ + this.key = key; + this.value = value; + } + + } + + public hashmap() { + } + + public void put(Object key, Object value){ + int pos = key.hashCode() % values.lenght(); + if (values[pos] == null){ + values[pos] = value; + return; + } + if(value[pos] instanceof ArrayList t){ + t.add(new tuple(key, value)); + return; + } + Object temp = values[pos]; + values[pos] = new ArrayList; + value[pos].add(temp); + value[pos].add(new tuple(key, value)); + } + + public Object get(Object key){ + int pos = key.hashCode() % values.lenght(); + if(values[pos].equals(key)){ + return values[pos].value; + } + if(values[pos] instanceof ArrayList t){ + for (v : t) { + if (v.key.equals(key)){ + return v.value + } + } + } + return null; + + } +} + diff --git a/q2/tp1/Cercle.java b/q2/algo/tp1/Cercle.java similarity index 100% rename from q2/tp1/Cercle.java rename to q2/algo/tp1/Cercle.java diff --git a/q2/tp1/Droites.java b/q2/algo/tp1/Droites.java similarity index 100% rename from q2/tp1/Droites.java rename to q2/algo/tp1/Droites.java diff --git a/q2/tp1/HelloWorld.java b/q2/algo/tp1/HelloWorld.java similarity index 100% rename from q2/tp1/HelloWorld.java rename to q2/algo/tp1/HelloWorld.java diff --git a/q2/tp1/Suite.java b/q2/algo/tp1/Suite.java similarity index 100% rename from q2/tp1/Suite.java rename to q2/algo/tp1/Suite.java diff --git a/q2/tp1/TP01.pdf b/q2/algo/tp1/TP01.pdf similarity index 100% rename from q2/tp1/TP01.pdf rename to q2/algo/tp1/TP01.pdf diff --git a/q2/tp2/Droite.java b/q2/algo/tp2/Droite.java similarity index 100% rename from q2/tp2/Droite.java rename to q2/algo/tp2/Droite.java diff --git a/q2/tp2/DroiteTest.java b/q2/algo/tp2/DroiteTest.java similarity index 100% rename from q2/tp2/DroiteTest.java rename to q2/algo/tp2/DroiteTest.java diff --git a/q2/tp2/Point.java b/q2/algo/tp2/Point.java similarity index 100% rename from q2/tp2/Point.java rename to q2/algo/tp2/Point.java diff --git a/q2/tp2/TP2.pdf b/q2/algo/tp2/TP2.pdf similarity index 100% rename from q2/tp2/TP2.pdf rename to q2/algo/tp2/TP2.pdf diff --git a/q2/tp2/hanoi.zip b/q2/algo/tp2/hanoi.zip similarity index 100% rename from q2/tp2/hanoi.zip rename to q2/algo/tp2/hanoi.zip diff --git a/q2/tp2/hanoi/src/tours_hanoi/HanoiFrame.java b/q2/algo/tp2/hanoi/src/tours_hanoi/HanoiFrame.java similarity index 100% rename from q2/tp2/hanoi/src/tours_hanoi/HanoiFrame.java rename to q2/algo/tp2/hanoi/src/tours_hanoi/HanoiFrame.java diff --git a/q2/tp2/hanoi/src/tours_hanoi/HanoiState.html b/q2/algo/tp2/hanoi/src/tours_hanoi/HanoiState.html similarity index 100% rename from q2/tp2/hanoi/src/tours_hanoi/HanoiState.html rename to q2/algo/tp2/hanoi/src/tours_hanoi/HanoiState.html diff --git a/q2/tp2/hanoi/src/tours_hanoi/HanoiState.java b/q2/algo/tp2/hanoi/src/tours_hanoi/HanoiState.java similarity index 100% rename from q2/tp2/hanoi/src/tours_hanoi/HanoiState.java rename to q2/algo/tp2/hanoi/src/tours_hanoi/HanoiState.java diff --git a/q2/tp2/hanoi/src/tours_hanoi/Tester.java b/q2/algo/tp2/hanoi/src/tours_hanoi/Tester.java similarity index 100% rename from q2/tp2/hanoi/src/tours_hanoi/Tester.java rename to q2/algo/tp2/hanoi/src/tours_hanoi/Tester.java diff --git a/q2/tp2/hanoi/src/tours_hanoi/stylesheet.css b/q2/algo/tp2/hanoi/src/tours_hanoi/stylesheet.css similarity index 100% rename from q2/tp2/hanoi/src/tours_hanoi/stylesheet.css rename to q2/algo/tp2/hanoi/src/tours_hanoi/stylesheet.css diff --git a/q2/tp2/recursif/.idea/.gitignore b/q2/algo/tp2/recursif/.idea/.gitignore similarity index 100% rename from q2/tp2/recursif/.idea/.gitignore rename to q2/algo/tp2/recursif/.idea/.gitignore diff --git a/q2/tp2/recursif/.idea/misc.xml b/q2/algo/tp2/recursif/.idea/misc.xml similarity index 100% rename from q2/tp2/recursif/.idea/misc.xml rename to q2/algo/tp2/recursif/.idea/misc.xml diff --git a/q2/tp2/recursif/.idea/modules.xml b/q2/algo/tp2/recursif/.idea/modules.xml similarity index 100% rename from q2/tp2/recursif/.idea/modules.xml rename to q2/algo/tp2/recursif/.idea/modules.xml diff --git a/q2/tp2/recursif/.idea/vcs.xml b/q2/algo/tp2/recursif/.idea/vcs.xml similarity index 100% rename from q2/tp2/recursif/.idea/vcs.xml rename to q2/algo/tp2/recursif/.idea/vcs.xml diff --git a/q2/tp2/recursif/recursif.iml b/q2/algo/tp2/recursif/recursif.iml similarity index 100% rename from q2/tp2/recursif/recursif.iml rename to q2/algo/tp2/recursif/recursif.iml diff --git a/q2/tp3/ExoArray.java b/q2/algo/tp3/ExoArray.java similarity index 100% rename from q2/tp3/ExoArray.java rename to q2/algo/tp3/ExoArray.java diff --git a/q2/tp3/ExoCmd.java b/q2/algo/tp3/ExoCmd.java similarity index 100% rename from q2/tp3/ExoCmd.java rename to q2/algo/tp3/ExoCmd.java diff --git a/q2/tp3/TP3.pdf b/q2/algo/tp3/TP3.pdf similarity index 100% rename from q2/tp3/TP3.pdf rename to q2/algo/tp3/TP3.pdf diff --git a/q2/cours2/Couple.class b/q2/cours2/Couple.class deleted file mode 100644 index c845b3d..0000000 Binary files a/q2/cours2/Couple.class and /dev/null differ diff --git a/q2/cours2/Division.class b/q2/cours2/Division.class deleted file mode 100644 index a953c46..0000000 Binary files a/q2/cours2/Division.class and /dev/null differ diff --git a/q2/fonctio/tp1/algo_q21.py b/q2/fonctio/tp1/algo_q21.py new file mode 100644 index 0000000..b112aef --- /dev/null +++ b/q2/fonctio/tp1/algo_q21.py @@ -0,0 +1,29 @@ +#!/bin/python + +def toBinaryString(user_i:int): + squares = [2**i for i in range(32)] + squares.reverse() + + ret = '' + show = False + + for s in squares: + if user_i & s: + ret += '1' + show=True + else: + if show: + ret += '0' + return ret + + +def main(): + """ + Ask the user for an input + """ + user_in = input("entrez un nombre :") + print(toBinaryString(int(user_in))) + + +if __name__ == "__main__": + main() diff --git a/q2/fonctio/tp1/exercices.md b/q2/fonctio/tp1/exercices.md new file mode 100644 index 0000000..1069d13 --- /dev/null +++ b/q2/fonctio/tp1/exercices.md @@ -0,0 +1,85 @@ +# Exercices + +## Binary + +1) \\( \\) + +2) 4095 + +3) 100000 (2) = 32 (10) +4) 000010 (2) = 2 (10) +5) 111111 (2) = 63 (10) +6) 010101 (2) = 21 (10) + +7) 64 (10) = 0100 0000 (2) +8) 7 (10) = 0000 0100 (2) +9) 192 (10) = 1100 0000 (2) +10) 3073 (10) = 0110 0000 0001 (2) + +11) 0x1010 = 4112 +12) 0x10A0 = 4256 +13) 0xBABE = 47806 + +14) 020 = 16 +15) 072 = 58 + +16) sur papier = 0xCAFE +17) sur papier = 02001 + +18) 0xCAFE = 1100 1010 1111 1110 +19) 0xCAFE = 0145376 +20) 072 = 111010 + +21) > ./algo_q21.py + +## Complement a 2 + +22) +23) \\( -2^11 → 2^11-1 \\) + +24) 17 = 0001 0001 +25) -17 = 1110 1101 +26) 255 = 1111 1111 (Imposible car pas dans l'interval) +27) -128 = 1000 0000 +28) -73 = 10110111 + +29) 01001111 + + 00000001 + = 01010000 + +30) - 10010110 = 01101010 + +31) 01001111 + + 01000001 + --------- + = 10010000 (Overflow, le nombre n'est pas dans la range de nombre accesible sur 8 bits en ca2) + +32) 00000001 + - 00000010 + ---------- + = 11111111 + +33) 00001001 + x 00000110 + ---------- + 000010010 + + 0000100100 + ------------ + = 0000110110 + +34) 10000001 + - 10000010 + ---------- + = 11111111 +35) - 10000000 = 011111111 (Imposible a representer sur 8 bits) + +36) 00010100 + / 00000101 + ---------- + 00000100 + +37) 00010111 + / 00001001 + ---------- + 00000010 (reste 101) +38) diff --git a/q2/fonctio/tp1/fonct-ordis-tp1-integers.pdf b/q2/fonctio/tp1/fonct-ordis-tp1-integers.pdf new file mode 100644 index 0000000..04d0bf3 Binary files /dev/null and b/q2/fonctio/tp1/fonct-ordis-tp1-integers.pdf differ diff --git a/q2/tp3/ExoArray.class b/q2/tp3/ExoArray.class deleted file mode 100644 index dd4f5e4..0000000 Binary files a/q2/tp3/ExoArray.class and /dev/null differ diff --git a/q2/tp3/ExoCmd.class b/q2/tp3/ExoCmd.class deleted file mode 100644 index 6bbfa91..0000000 Binary files a/q2/tp3/ExoCmd.class and /dev/null differ