TradAion

shootangel Messages postés 4 Date d'inscription lundi 1 février 2010 Statut Membre Dernière intervention 23 mars 2010 - 21 mars 2010 à 04:10
shootangel Messages postés 4 Date d'inscription lundi 1 février 2010 Statut Membre Dernière intervention 23 mars 2010 - 23 mars 2010 à 13:18
Bonjour,

Voila j'ai un projet mais je ne sais pas comment mis prendre c'est pour cela que je m'adresse a vous programmeurs....

j'aimerais apprendre ou savoir comment faire un traducteur de langue.

enfaite je sais cela:

Elyséen: a b c d e f g h i j k l m n o p q r s t u v w x y z Asmodien: i h k j m l o n q p s r u t w v y x a z c b e d g f

C'est a dire que quand un élyséen dit "stop" un asmodien reçois "azwv"

voilu, merci et a bientôt

6 réponses

cs_rt15 Messages postés 3874 Date d'inscription mardi 8 mars 2005 Statut Modérateur Dernière intervention 7 novembre 2014 13
21 mars 2010 à 17:39
Bonjour,

Travaille avec les caractères comme avec des entiers.

Fait un tableau de char asmodien contenant i h k j m l o n q p s r u t w v y x a z c b e d g f.
asmodien[26] = { 'i', 'h', ... };
Et ensuite, quelque chose comme ça ->

i = 0;
tant que tab[i] faire
  si (tab[i] >= 'a') et (tab[i] <= 'z') alors
    tab[i] = asmodien[tab[i] - 'a'];
  fsi;
  i++;
fait;
0
shootangel Messages postés 4 Date d'inscription lundi 1 février 2010 Statut Membre Dernière intervention 23 mars 2010
21 mars 2010 à 18:45
Donc la deuxième c'est


i = 0;
tant que tab[i] faire
si (tab[i] >= 'b') et (tab[i] <= 'h') alors
tab[i] = asmodien[tab[i] - 'b'];
fsi;
i++;
fait;



ou




b = 0;
tant que tab[b] faire
si (tab[b] >= 'h') et (tab[b] <= 'z') alors
tab[b] = asmodien[tab[b] - 'h'];
fsi;
i++;
fait;
0
cs_rt15 Messages postés 3874 Date d'inscription mardi 8 mars 2005 Statut Modérateur Dernière intervention 7 novembre 2014 13
21 mars 2010 à 19:45
Non non. Ca fait toutes les lettres en une passe.
tab[i] = asmodien[tab[i] - 'a'];


Si c'est un tab[i] est un "e" par exemple...
->
tab[i] = asmodien['e' - 'a'];
Table ascii...
->
tab[i] = asmodien[101 - 97];
->
tab[i] = asmodien[4];
Les tableaux C sont indicés de 0 à n - 1...
->
tab[i] = 'm';

Et ainsi de suite pour toutes les lettre de tab qui sont des lettres entre a et z jusqu'au zéro terminal (On avance avec le i++). Attention, les majuscules ne sont pas traitées par contre.
0
shootangel Messages postés 4 Date d'inscription lundi 1 février 2010 Statut Membre Dernière intervention 23 mars 2010
22 mars 2010 à 12:35
tableau de char asmodien

asmodien[26] = { 'i', 'h', 'k', 'j', 'm', 'l', 'o', 'n', 'q', 'p', 's', 'r', 'u', 't', 'w', 'v', 'y', 'x', 'a', 'z', 'c', 'b', 'e', 'd', 'g', 'f', };


tableau de char elyséen

elyséen[26] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', };


tab[i] = asmodien[tab[i] - 'a'];
tab[i] = asmodien[tab[h] - 'b'];
tab[i] = asmodien[tab[k] - 'c'];
tab[i] = asmodien[tab[j] - 'd'];
tab[i] = asmodien[tab[m] - 'e'];
tab[i] = asmodien[tab[l] - 'f'];
tab[i] = asmodien[tab[o] - 'g'];
tab[i] = asmodien[tab[n] - 'h'];
tab[i] = asmodien[tab[q] - 'i'];
tab[i] = asmodien[tab[p] - 'j'];
tab[i] = asmodien[tab[s] - 'k'];
tab[i] = asmodien[tab[r] - 'l'];
tab[i] = asmodien[tab[u] - 'm'];
tab[i] = asmodien[tab[t] - 'n'];
tab[i] = asmodien[tab[w] - 'o'];
tab[i] = asmodien[tab[v] - 'p'];
tab[i] = asmodien[tab[y] - 'q'];
tab[i] = asmodien[tab[x] - 'r'];
tab[i] = asmodien[tab[c] - 's'];
tab[i] = asmodien[tab[z] - 't'];
tab[i] = asmodien[tab[c] - 'u'];
tab[i] = asmodien[tab[b] - 'v'];
tab[i] = asmodien[tab[e] - 'w'];
tab[i] = asmodien[tab[d] - 'x'];
tab[i] = asmodien[tab[g] - 'y'];
tab[i] = asmodien[tab[f] - 'z'];

comme cela ?
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_rt15 Messages postés 3874 Date d'inscription mardi 8 mars 2005 Statut Modérateur Dernière intervention 7 novembre 2014 13
22 mars 2010 à 14:34
Heu...

Il ne faut pas écrire du code au hasard. Il faut commencer par une étape de conception. Dans cet étape, il faut avant tout réfléchir, poser le problème et trouver un algo le solutionnant. Ensuite on code.

Autre point important, le développeur n'aime pas travailler. Il laisse faire l'ordinateur. Donc quand on fait un code, on le fait dense et sans répétitions. Si tu appuis sur ctrl + C et ctrl + V lorsque tu code c'est qu'il y a un problème dans ton algo. Faut faire une fonction ou une boucle.

#include <stdio.h>

char asmodien[26] = { 'i', 'h', 'k', 'j', 'm', 'l', 'o', 'n', 'q', 'p', 's', 'r', 'u', 't', 'w', 'v', 'y', 'x', 'a', 'z', 'c', 'b', 'e', 'd', 'g', 'f' };

int main ()
{
  char tab[200];
  int i;

  gets(tab);
  
  i = 0;
  while (tab[i])
  {
    if ((tab[i] >= 'a') && (tab[i] <= 'z'))
      tab[i] = asmodien[tab[i] - 'a'];
    i++;
  }

  puts(tab);

  return 0;
}
0
shootangel Messages postés 4 Date d'inscription lundi 1 février 2010 Statut Membre Dernière intervention 23 mars 2010
23 mars 2010 à 13:18
DONC

#include <stdio.h>

char asmodien[26] = { 'i', 'h', 'k', 'j', 'm', 'l', 'o', 'n', 'q', 'p', 's', 'r', 'u', 't', 'w', 'v', 'y', 'x', 'a', 'z', 'c', 'b', 'e', 'd', 'g', 'f' };

int main ()
{
char tab[200];
int i;

gets(tab);

i = 0;
while (tab[i])
{
if ((tab[i] >= 'a') && (tab[i] <= 'z'))
tab[i] = asmodien[tab[i] - 'a'];
i++;
}

puts(tab);

return 0;
}

#include <stdio.h>

char elyséen[26] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', };

int main ()
{
char tab[200];
int i;

gets(tab);

i = 0;
while (tab[i])
{
if ((tab[i] >= 'a') && (tab[i] <= 'z'))
tab[i] = asmodien[tab[i] - 'a'];
i++;
}

puts(tab);

return 0;
}
0
Rejoignez-nous