Ajout de la lecture du ficher
authorjerome <jerome@fac>
Thu, 7 Nov 2013 12:47:41 +0000 (13:47 +0100)
committerjerome <jerome@fac>
Thu, 7 Nov 2013 12:47:41 +0000 (13:47 +0100)
Prog.java [deleted file]
permutations.txt [new file with mode: 0644]
src/CollPaires.java [moved from CollPaires.java with 100% similarity]
src/Paire.java [moved from Paire.java with 100% similarity]
src/Permutation.java [moved from Permutation.java with 98% similarity]
src/Prog.java [new file with mode: 0644]

diff --git a/Prog.java b/Prog.java
deleted file mode 100644 (file)
index c77c916..0000000
--- a/Prog.java
+++ /dev/null
@@ -1,15 +0,0 @@
-/**
-@author jerome et adrien
-*/
-public class Prog
-{
-       public static void main(String[] args)
-       {
-               Permutation p = new Permutation();
-               p.setN(50);
-               p.genRandom();
-               System.out.println(p.eltsToString());
-               p.chercherMin();
-               System.out.println(p.minsToString());
-       }
-}
diff --git a/permutations.txt b/permutations.txt
new file mode 100644 (file)
index 0000000..342b74d
--- /dev/null
@@ -0,0 +1,8 @@
+2 ( 1 2 )
+3 ( 3 2 1 )
+4 ( 2 4 1 3 )
+5 ( 3 5 2 4 1 )
+6 ( 1 3 6 4 5 2 )
+7 ( 4 5 6 2 1 3 7 )
+8 ( 5 4 3 8 6 7 2 3 )
+9 ( 3 4 8 6 1 5 2 7 9 )
similarity index 100%
rename from CollPaires.java
rename to src/CollPaires.java
similarity index 100%
rename from Paire.java
rename to src/Paire.java
similarity index 98%
rename from Permutation.java
rename to src/Permutation.java
index b66d892..beb91cd 100644 (file)
@@ -54,7 +54,7 @@ public class Permutation
                        idVMin = -1;
                        idVMax = -1;
                        j = 0;
-      //recherche de l'interval
+      //recherche de l'intervalle
                        while (idVMin == -1 || idVMax == -1)
                        {
                                if (elts[j] == t+1)
diff --git a/src/Prog.java b/src/Prog.java
new file mode 100644 (file)
index 0000000..1539a6a
--- /dev/null
@@ -0,0 +1,57 @@
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.util.Scanner;
+
+
+public class Prog
+{
+       final static String pathPermutation="/comptes/E115567R/L3/Algorithmique & Structures de donnĂ©es 3/TP/Projet/A&SD3-Projet/permutations.txt";
+       public static Permutation load(int l)
+       {
+               int n;
+               int[] elts;
+               Permutation p = null;
+               try
+               {
+                       Scanner sc = new Scanner(new FileReader(pathPermutation));
+                       for (int i=1; i < l; i++) 
+                       {
+                               if (sc.hasNextLine())
+                                       sc.nextLine();
+                       }
+                       if (sc.hasNextLine()) {
+                               n = sc.nextInt();
+                               elts = new int[n];
+                               sc.next();
+                               for (int i = 0; i < n ; i++)
+                               {
+                                       elts[i] = sc.nextInt();
+                               }
+                               p = new Permutation(n,elts);
+                       }
+                       sc.close();
+               } catch (Exception e)
+               {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+               return p;
+       }
+       
+       public static Permutation load() {
+               return load(1);
+       }
+       public static Permutation[] loadAll()
+       {
+               Permutation[] p = new Permutation[5];
+               return p;
+       }
+       
+       public static void main(String[] args)
+       {
+               Permutation p = load(1);
+               System.out.println(p.eltsToString());
+               p.chercherMin();
+               System.out.println(p.minsToString());           
+       }
+}