permutations.txt without space
authorDralagen <dralagen@dralagen.fr>
Thu, 7 Nov 2013 13:43:06 +0000 (14:43 +0100)
committerDralagen <dralagen@dralagen.fr>
Thu, 7 Nov 2013 13:43:06 +0000 (14:43 +0100)
permutations.txt [changed mode: 0644->0755]
src/Prog.java

old mode 100644 (file)
new mode 100755 (executable)
index 342b74d..5df665e
@@ -1,8 +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 )
+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)
index 1539a6a..747b5a8 100644 (file)
@@ -5,7 +5,7 @@ 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";
+       final static String pathPermutation="permutations.txt";
        public static Permutation load(int l)
        {
                int n;
@@ -14,7 +14,7 @@ public class Prog
                try
                {
                        Scanner sc = new Scanner(new FileReader(pathPermutation));
-                       for (int i=1; i < l; i++) 
+                       for (int i=1; i < l; i++)
                        {
                                if (sc.hasNextLine())
                                        sc.nextLine();
@@ -22,22 +22,24 @@ public class Prog
                        if (sc.hasNextLine()) {
                                n = sc.nextInt();
                                elts = new int[n];
-                               sc.next();
+                               String buff;
                                for (int i = 0; i < n ; i++)
                                {
-                                       elts[i] = sc.nextInt();
+                                       buff = sc.next();
+                                       buff = buff.replace(")","");
+                                       buff = buff.replace("(","");
+                                       elts[i] = Integer.parseInt(buff);
                                }
                                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);
        }
@@ -46,12 +48,12 @@ public class Prog
                Permutation[] p = new Permutation[5];
                return p;
        }
-       
+
        public static void main(String[] args)
        {
-               Permutation p = load(1);
+               Permutation p = load(4);
                System.out.println(p.eltsToString());
                p.chercherMin();
-               System.out.println(p.minsToString());           
+               System.out.println(p.minsToString());
        }
 }