Affichage des nombre de 11 à19

tenohthree Messages postés 55 Statut Membre -  
tenohthree Messages postés 55 Statut Membre -
Bonjour,
j'ai développé un programme qui converti d'un chiffre écrit littéralement en un entier
le principe est de répartir des tableaux : unité, dizaine etc...
#include<stdio.h>
#include<string.h>
#include<conio.h>

 main()
{
char l1[50],l2[50],l3[50],l4[50], lettre[256];
char *espace = " ";
char unite[25][10]={"","un","deux","trois","quatre", "cinq", "six", "sept", "huit","neuf"};
char dizaine[11][20]={"","","vignt","trente","quarante","cinquante","soixante","soixante-dix","quatre-vignt","quatre-vignt-dix"};
char centaine[5][9]={"","cent","cents"};
int s,i,x1,x2,x3,x4;
strcpy(lettre,"");
printf("donner une chiffre literalement\n");
scanf("%s\n",&l1);
scanf("%s\n",&l2);
scanf("%s\n",&l3);
scanf("%s\n",&l4);

strcat(lettre,l1);
strcat(lettre,espace);
strcat(lettre,l2);
strcat(lettre,espace);
strcat(lettre,l3);
strcat(lettre,espace);
strcat(lettre,l4);

printf("%s\n",lettre);

for(i=0;i<10 || (strcmp(l1,unite[i])==0) ;i++)
if (strcmp(l1,unite[i])==0)
x1=i;

for(i=0;i<4 || (strcmp(l2,centaine[i])==0) ;i++)
if (strcmp(l2,centaine[i])==0)
x2=100;

for(i=0;i<11 || (strcmp(l3,dizaine[i])==0) ;i++)
if (strcmp(l3,dizaine[i])==0)
x3=10*i;

for(i=0;i<10 || (strcmp(l4,unite[i])==0) ;i++)
if (strcmp(l4,unite[i])==0)
x4=i;

printf(" ca fait :%d  ",x1*x2+x3+x4);

getch();
return 0;
}

jusqu'à maintenant tout est çava...sauf des nombre qui contient de chiffres de 11 à 19 commet 95 et 76 etc...
avez vous une idée pour afficher des nombre entre 11 et 19?
A voir également:

1 réponse

tenohthree Messages postés 55 Statut Membre
 
merci d'avance
0