Compare commits

...

1 Commits

Author SHA1 Message Date
53e82c7673 Correction Cesar 2019-06-01 18:27:38 +02:00
2 changed files with 20 additions and 2 deletions

View File

@ -13,7 +13,16 @@ public class CesarChiffre {
// int position(char c): retourne la position de la lettre dans l'alphabet
// (à partir de 0)
return in;
char[] out = new char[in.length];
for (int i = 0; i<in.length; i++) {
char c = in[i];
if (c == ' ') {
out[i] = c;
} else {
out[i] = ALPHABET[(position(c)+cle) % ALPHABET.length];
}
}
return out;
}
}

View File

@ -13,7 +13,16 @@ public class CesarDechiffre {
// int position(char c): retourne la position de la lettre dans l'alphabet
// (à partir de 0)
return in;
char[] out = new char[in.length];
for (int i = 0; i<in.length; i++) {
char c = in[i];
if (c == ' ') {
out[i] = c;
} else {
out[i] = ALPHABET[(ALPHABET.length+position(c)-cle) % ALPHABET.length];
}
}
return out;
}
}