Ce code traduire toutes les dates valides entre 1995 et 2005 saisies jj mm aaaa et les restituent en texte.
Source / Exemple :
program LIREDATE;
uses
Forms;
VAR date : STRING[10];
jour : STRING[2];
mois : STRING[2];
annee : STRING[4];
transa, transm, transj : string;
begin
WRITELN('inscrivez la date a convertir sous forme jj mm aaaa');
READLN (date);
jour :=COPY(date,1,2);
mois :=COPY(date,4,5);
annee :=COPY(date,7,8);
Begin{traduction de l'annee}
IF annee = '1995' then
transa := 'mille neuf cent quatre-vingt quinze'
ELSE
IF annee = '1996' then
transa := 'mille neuf cent quatre-vingt seize'
ELSE
IF annee = '1997' then
transa := 'mille neuf cent quatre-vingt dix-sept'
ELSE
IF annee = '1998' then
transa := 'mille neuf cent quatre-vingt dix-huit'
ELSE
IF annee = '1999' then
transa := 'mille neuf cent quatre-vingt dix-neuf'
ELSE
IF annee = '2000' then
transa := 'deux mille'
ELSE
IF annee = '2001' then
transa := 'deux mille un'
ELSE
IF annee = '2002' then
transa := 'deux mille deux'
ELSE
IF annee = '2003' then
transa := 'deux mille trois'
ELSE
IF annee = '2004' then
transa := 'deux mille quatre'
ELSE
IF annee = '2005' then
transa := 'deux mille cinq'
ELSE writeln('l''annee est incorrecte');
End;{fin de la traduction de l'annee}
Begin{traduction du mois}
IF mois = '01' then
transm := 'janvier'
ELSE
IF mois = '02' then
transm := 'fevrier'
ELSE
IF mois = '03' then
transm := 'mars'
ELSE
IF mois = '04' then
transm := 'avril'
ELSE
IF mois = '05' then
transm := 'mai'
ELSE
IF mois = '06' then
transm := 'juin'
ELSE
IF mois = '07' then
transm := 'juillet'
ELSE
IF mois = '08' then
transm := 'aout'
ELSE
IF mois = '09' then
transm := 'septembre'
ELSE
IF mois = '10' then
transm := 'octobre'
ELSE
IF mois = '11' then
transm := 'novembre'
ELSE
IF mois = '12' then
transm := 'decembre'
ELSE writeln('le mois est incorrect');
end;{fin de la traduction du mois}
Begin
IF jour = '01' then
transj := 'premier'
ELSE
IF jour = '02' then
transj := 'deux'
ELSE
IF jour = '03' then
transj := 'trois'
ELSE
IF jour = '04' then
transj := 'quatre'
ELSE
IF jour = '05' then
transj := 'cinq'
ELSE
IF jour = '06' then
transj := 'six'
ELSE
IF jour = '07' then
transj := 'sept'
ELSE
IF jour = '08' then
transj := 'huit'
ELSE
IF jour = '09' then
transj := 'neuf'
ELSE
IF jour = '10' then
transj := 'dix'
ELSE
IF jour = '11' then
transj := 'onze'
ELSE
IF jour = '12' then
transj := 'douze'
ELSE
IF jour = '13' then
transj := 'treize'
ELSE
IF jour = '14' then
transj := 'quatorze'
ELSE
IF jour = '15' then
transj := 'quinze'
ELSE
IF jour = '16' then
transj := 'seize'
ELSE
IF jour = '17' then
transj := 'diz-sept'
ELSE
IF jour = '18' then
transj := 'dix-huit'
ELSE
IF jour = '19' then
transj := 'dix-neuf'
ELSE
IF jour = '20' then
transj := 'vingt'
ELSE
IF jour = '21' then
transj := 'vingt et un'
ELSE
IF jour = '22' then
transj := 'vingt-deux'
ELSE
IF jour = '23' then
transj := 'vingt-trois'
ELSE
IF jour = '24' then
transj := 'vingt-quatre'
ELSE
IF jour = '25' then
transj := 'vingt-cinq'
ELSE
IF jour = '26' then
transj := 'vingt-six'
ELSE
IF jour = '27' then
transj := 'vingt-sept'
ELSE
IF jour = '28' then
transj := 'vingt-huit'
ELSE{Prb annee bisextille}
IF jour = '29' then
IF mois = '02' then
IF annee = '1996' then
transj :='vingt-neuf'
else if annee = '2000' then
transj :='vingt-neuf'
else if annee = '2004' then
transj :='vingt-neuf'
else writeln('le jour est incorrect')
else transj :='vingt-neuf'
ELSE
IF jour = '30' then
IF mois = '02' then
writeln ('le jour est incorrect')
Else transj := 'trente'
ELSE{Prb mois a 31 jours}
IF jour = '31' then
IF mois = '02' then
Writeln('le jour est incorrect')
Else if mois = '04' then
Writeln('le jour est incorrect')
Else if mois = '06' then
Writeln('le jour est incorrect')
Else if mois = '09' then
Writeln('le jour est incorrect')
Else if mois = '11' then
Writeln('le jour est incorrect')
Else transj :='trente et un'
ELSE writeln('le jour est incorrect');
end;{fin de la traduction du mois}
WRITELN (transj, ' ', transm, ' ', transa);
Readln;
end.
Conclusion :
C'est une vraie usine a gaz mais c'est de mon niveau
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.