برنامج تحويل الاعداد- عربي فرنسي-
#7
كود :
function NombreEnLettres(n: Integer): string; Const unite: array [1 .. 19] of string = ('un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze', 'quinze', 'seize', 'dix sept', 'dix huit', 'dix neuf'); dizaineF: array [2 .. 9] of string = ('vingt', 'trente', 'quarante', 'cinquante', 'soixante', '', 'quatre-vingt', ''); dizaineB: array [2 .. 9] of string = ('vingt', 'trente', 'quarante', 'cinquante', 'soixante', 'septante', 'octante', 'nonante'); coefs: array [0 .. 3] of string = ('cent', 'mille', 'million', 'milliard'); Var temp: String; c, d, u: Integer; coef: Integer; I: Integer; neg: Boolean; Begin Result := ''; // Cas particulier de zéro If n = 0 then begin Result := ' zero'; Exit; end; // Mémorisation du signe neg := n < 0; If neg then n := -n; coef := 0; Repeat // Récupération de l'unité du bloc de trois chiffres en cours u := n mod 10; n := n div 10; // Récupération de la dizaine du bloc de trois chiffres en cours d := n mod 10; n := n div 10; // Traitement des dizaines temp := ''; // Passage sur la dizaine inférieure pour 10 à 19 // et pour 70-79 90-99 dans le cas de la France If (d = 1) Or ((d in [7, 9])) then begin Dec(d); Inc(u, 10); end; if d > 1 then begin temp := ' ' + dizaineF[d]; // Ajout du cas particulier de 'et' entre la dizaine et 1 if (d < 8) and ((u = 1) or (u = 11)) then temp := temp + ' et'; end; // ajout du texte de l'unité if u > 0 then temp := temp + ' ' + unite[u]; // ajout du 's' à Quatre-vingt si rien ne suit If (Result = '') and (d = 8) and (u = 0) then Result := 's'; Result := temp + Result; // Récupération de la centaine du bloc de trois chiffres en cours c := n mod 10; n := n div 10; { Récupère centaine } If c > 0 then begin temp := ''; if c > 1 then temp := ' ' + unite[c] + temp; temp := temp + ' ' + coefs[0]; // Traitement du cas particulier du 's' à cent si rien ne suit If (Result = '') and (c > 1) then Result := 's'; Result := temp + Result; end;

// Traitement du prochain groupe de 3 chiffres
الرد


الردود في هذا الموضوع
برنامج تحويل الاعداد- عربي فرنسي- - بواسطة sami2008 - 17-04-2010, 11:26 AM

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم