Bonjour,

quand je fais tourner ma boucle je ne comprend pas quand i passe de 0 a 1 la valeur de i=0 est modifie aussi
j'ai beau faire tourner a la main je ne trouve pas l'erreur
Si quelqu'un a une idee???

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
public class Crypto {
 
    static final String ALPHABET = "abcdefghijklmnopqrstuvwxyz";
    static final int DECALAGE = 4;
 
    static Scanner scanner = new Scanner(System.in);
 
    public static void main(String[] args) {
 
        System.out.println("Veuillez entrer une chaine de caracteres : ");
        //String s = scanner.nextLine();
       String s ="Avez-vous Vu mes 3 chats et mes 2 chiens ?";
        // la chaine a coder
        String aCoder = "";
        // la chaine codee
        String chaineCodee = "";
 
        /*******************************************
         * Completez le programme a partir d'ici.
         *******************************************/
        s.intern();
        String ALPHA=ALPHABET+" ";		
        String aCode;
        aCode=s;
 
        Pattern p = Pattern.compile("(-)|\\b!?(\\d.)|(\\p{Upper}?)|(!\\S)?|(\\W)") ;
        Matcher m = p.matcher(aCode) ; 
 
        String aCoderemplace = m.replaceAll("");
 
        aCoder=aCoderemplace;
 
 
        for(int i=0;i<aCoder.length();i++)
        {
        	for(int j=0;j<ALPHA.length();j++)
        	{      
        		if(aCoder.charAt(i) == ALPHA.charAt(j))
        		{        
 
        			if(j<22)
        			{    
          				chaineCodee=chaineCodee+aCoder.charAt(i);    
        				chaineCodee=chaineCodee.replace(chaineCodee.charAt(i), ALPHA.charAt(j+DECALAGE));	
        			}
        			if(j>22)
        			{
        				chaineCodee=chaineCodee+aCoder.charAt(i);
        				chaineCodee=chaineCodee.replace(chaineCodee.charAt(i), ALPHA.charAt((j+DECALAGE)%26));
        			}
        			if(ALPHA.charAt(26)==aCoder.charAt(i))
        			{
        				chaineCodee=chaineCodee.replace(chaineCodee.charAt(i),ALPHA.charAt(26));
        			}
        		}
        	}	
        }
 
 
        /*******************************************
         * Ne rien modifier apres cette ligne.
         *******************************************/
    	System.out.println(aCoder);
    	System.out.format("La chaine initiale etait : '%s'\n", s);
 
        if (aCoder.isEmpty()) {
            System.out.println("La chaine a coder est vide.\n");
        } else {
            System.out.format("La chaine a coder est : '%s'\n", aCoder);
            System.out.format("La chaine codee est : '%s'\n", chaineCodee);
        }
    }
}

Merci pour vos reponse...