richie3366

Nombres en français v1

Oct 17th, 2012
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 2.75 KB | None | 0 0
  1. with entrees_sorties;
  2. use entrees_sorties;
  3.  
  4.  
  5. procedure nbrfr is
  6.    
  7.     nbGet : Integer;
  8.    
  9.     listeVals : array(1..27) of Integer := (1000000000, 1000000, 1000, 100, 80, 80, 60, 50, 40, 30, 20, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
  10.     listeStrings : array(1..27) of String(1..13) := ("milliard     ", "million      ", "mille        ", "cent         ", "quatre-vingts", "quatre-vingt ", "soixante     ", "cinquante    ", "quarante     ", "trente       ", "vingt        ", "seize        ", "quinze       ", "quatorze     ", "treize       ", "douze        ", "onze         ", "dix          ", "neuf         ", "huit         ", "sept         ", "six          ", "cinq         ", "quatre       ", "trois        ", "deux         ", "un           ");
  11.     listeStringSizes : array(1..27) of Integer := (8, 7, 5, 4, 13, 12, 8, 9, 8, 6, 5, 5, 6, 8, 6, 5, 4, 3, 4, 4, 4, 3, 4, 6, 5, 4, 2);
  12.     compteQte : array(1..27) of Integer := (1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  13.     plurAndUnit : array(1..27) of Integer := (1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  14.     exactRequis : array(1..27) of Integer := (0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  15.     requiertTiretEt : array(1..27) of Integer := (0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  16.     offreTiretEt : array(1..27) of Integer := (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
  17.  
  18.     mettreTiret : Boolean := FALSE;
  19.     precRequiertTiretEt : Boolean := FALSE;
  20.     precRequiertTiret : Boolean := FALSE;
  21.  
  22.     procedure afficherNombre(nbInit : Integer) is
  23.         i : Integer := 0;
  24.         j : Integer := 1;
  25.         nb : Integer;
  26.         val : Integer;
  27.     begin
  28.         nb := nbInit;
  29.         for i in 1..27 loop
  30.             --i := i + 1;
  31.             val := listeVals(i);
  32.             if((exactRequis(i)=1 AND nb=val) OR (nb >= val AND exactRequis(i)=0)) then
  33.                
  34.                 if(mettreTiret) then put('-'); end if;         
  35.                
  36.                 if(nb/val > 1) then
  37.                     afficherNombre(nb/val);
  38.                 elsif(nb/val=1 AND plurAndUnit(i)=1) then
  39.                     afficherNombre(1);
  40.                     mettreTiret := FALSE;
  41.                 end if;
  42.                
  43.                 if(precRequiertTiretEt AND offreTiretEt(i)=1) then
  44.                     put("-et-");
  45.                 elsif(precRequiertTiret AND plurAndUnit(i)/=1) then
  46.                     put('-');
  47.                 else
  48.                     put(' ');
  49.                 end if;
  50.                
  51.                 j := 1;
  52.  
  53.                 while(j <= listeStringSizes(i)) loop
  54.                     put(listeStrings(i)(j));
  55.                     j := j+1;
  56.                 end loop;
  57.                
  58.                
  59.                 precRequiertTiretEt := requiertTiretEt(i)=1;
  60.                 precRequiertTiret := plurAndUnit(i)/=1;
  61.                
  62.                
  63.                 nb := nb mod val;      
  64.                
  65.             end if;
  66.            
  67.         end loop;
  68.        
  69.     end afficherNombre;
  70.    
  71. begin
  72.    
  73.     put("Entrez un nombre : ");
  74.     get(nbGet);
  75.    
  76.     new_line;  
  77.     afficherNombre(nbGet);
  78.     new_line;  
  79.  
  80. end nbrfr;
Advertisement
Add Comment
Please, Sign In to add comment