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 52 53 54 55 56 57
| with Ada.Text_Io, Ada.Integer_Text_Io;
use Ada.Text_Io, Ada.Integer_Text_Io;
procedure Chiffres_Romains is
N,I: Integer;
Rom: String(1..14);
begin
Put_line ("donne un chiffre");
Get (N);
I:=1;
loop
if N>=1000 then
Rom(I):='M';
I:=I+1;
N:=N-1000;
elsif N>=500 then
Rom(I):='D';
I:=I+1;
N:=N-500;
elsif N>=100 then
Rom(I):='C';
I:=I+1;
N:=N-100;
elsif N>=50 then
Rom(I):='L';
I:=I+1;
N:=N-50;
elsif N>=10 then
Rom(I):='X';
I:=I+1;
N:=N-10;
elsif N>=5 then
Rom(I):='V';
I:=I+1;
N:=N-5;
elsif N>=1 then
Rom(I):='I';
I:=I+1;
N:=N-1;
end if;
exit when N=0;
end loop;
loop
exit when I=20;
Rom(I):=' ';
I:=I+1;
end loop;
Put (Rom);
end Chiffres_Romains; |
Partager