begin process at 2012 02 11 09:01:28
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Divers

 > TRANSFORMER UN ENTIER EN CHIFFRES ROMAINS

TRANSFORMER UN ENTIER EN CHIFFRES ROMAINS


 Information sur la source

Note :
3 / 10 - par 1 personne
3,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Divers Niveau :Débutant Date de création :06/12/2002 Date de mise à jour :06/12/2002 18:29:46 Vu :6 476

Auteur : fabiin

Ecrire un message privé
Site perso
Commentaire sur cette source (1)
Ajouter un commentaire et/ou une note

 Description

Petite fonction qui retourne un entier un chiffres romains
seulement entre 1 et 9999 !

Source

  • function ChiffresRomains(Nombre: integer): string;
  • const
  • LetUnit:array[0..9] of string=('','I','II','III','IV','V','VI','VII','VIII','IX');
  • LetDix:array[0..9] of string=('','X','XX','XXX','XL','L','LX','LXX','LXXX','XC');
  • LetCent:array[0..9] of string=('','C','CC','CCC','CD','D','DC','DCC','DCCC','CM');
  • LetMill:array[0..9] of string= ('','M','MM','MMM','MMMM','MMMMM','MMMMMM','MMMMMMM','MMMMMMMM','MMMMMMMMM');
  • var
  • centaines,dixaines,unite,milliers:integer;
  • Nmbr,Fin:string;
  • begin
  • Nmbr := inttostr(Nombre);
  • Unite := 0;
  • centaines:=0;
  • dixaines := 0;
  • milliers := 0;
  • //décompose le nombre
  • //unite:
  • if Length(Nmbr)>0 then
  • unite := strtoint(copy(Nmbr,Length(Nmbr),1));
  • //dixaines:
  • if Length(Nmbr)>1 then
  • dixaines := strtoint(copy(Nmbr,Length(Nmbr)-1,1));
  • //centaines:
  • if Length(Nmbr)>2 then
  • centaines := strtoint(copy(Nmbr,Length(Nmbr)-2,1));
  • //milliers
  • if Length(Nmbr)>3 then
  • milliers := strtoint(copy(Nmbr,1,Length(Nmbr)-3));
  • Fin := LetUnit[unite];
  • Fin := LetDix[dixaines] + Fin;
  • Fin := LetCent[centaines] + Fin;
  • Fin := LetMill[milliers] + Fin;
  • Result := Fin;
  • end;
function ChiffresRomains(Nombre: integer): string;
const
LetUnit:array[0..9] of string=('','I','II','III','IV','V','VI','VII','VIII','IX');
LetDix:array[0..9] of string=('','X','XX','XXX','XL','L','LX','LXX','LXXX','XC');
LetCent:array[0..9] of string=('','C','CC','CCC','CD','D','DC','DCC','DCCC','CM');
LetMill:array[0..9] of string= ('','M','MM','MMM','MMMM','MMMMM','MMMMMM','MMMMMMM','MMMMMMMM','MMMMMMMMM');
var
centaines,dixaines,unite,milliers:integer;
Nmbr,Fin:string;
begin
Nmbr := inttostr(Nombre);
Unite := 0;
centaines:=0;
dixaines := 0;
milliers := 0;
//décompose le nombre
//unite:
if Length(Nmbr)>0 then
unite := strtoint(copy(Nmbr,Length(Nmbr),1));
//dixaines:
if Length(Nmbr)>1 then
dixaines := strtoint(copy(Nmbr,Length(Nmbr)-1,1));
//centaines:
if Length(Nmbr)>2 then
centaines := strtoint(copy(Nmbr,Length(Nmbr)-2,1));
//milliers
if Length(Nmbr)>3 then
milliers := strtoint(copy(Nmbr,1,Length(Nmbr)-3));

Fin := LetUnit[unite];
Fin := LetDix[dixaines] + Fin;
Fin := LetCent[centaines] + Fin;
Fin := LetMill[milliers] + Fin;
Result := Fin;
end;

 Conclusion

Je sais, c'est très barbare comme j'ai fais ca (et pas de jeux de mots stupids)


 Sources du même auteur

Source avec Zip CAPTUER LE SON SORTANT ET L'ENREGISTRER DANS UN FICHIER WAV
CALCUL D'UNE MOYENNE
CHANGER LA DURÉE D'AFFICHAGE DES BULLES D'AIDES (HINT)
Source avec Zip Source avec une capture ASCII-T : PETIT SOFT D'ASCII ART.
CHANGER CONTRASTE / LUMINOSITÉ (L'ALGORITHME)

 Sources de la même categorie

Source avec Zip TRI DBRID CROISSANT ET DECROISSANT par walidlam
Source avec Zip PETITE APPLICATION DE RETENUE par walidlam
Source avec Zip APPLICATION ALIAS+EXCEL par walidlam
Source avec Zip ACCÈS À DIFFÉRENTES PROPRITÉS D'UNE FORME PARENT À PARTIR DE... par ioda19
CODAGE EN BASE64 DE CHAÎNES UNICODE par gta126

Commentaires et avis

Commentaire de g0belin le 23/12/2002 23:00:19

Muharf a l'ecole on a develloper un algo vachement mieux faudra que je le send !

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 1,466 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales