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
|
#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;
} |
Partager