تحويل الأرقام الى أرقام رومانية
#1
السلام عليكم جميعا وكيف حالكم

كنت احاول مع برنامج تحويل الأرقام من رقم عادي الى أرقام رومانية (حروف) او رموز

بحثت في الانترنيت وجدت هذا الرموز وكل شئ صحيح والتنفيذ :mad:

كود :
[align=left] program conversion; . var nb:intger; {nombre decimal} I,V,X,L,C,D,M:char; a,b,f:char; n:integer; j,g,h,t,w,e,o,p,q,r,s:integer procedure convers(n:integer;a,b,f:char); begin case n of l:write(a); 2:write(a,a); 3:write(a,a,a); 4:write(a,b); 5:write (b); 6:write(b,a); 7:wriLe(b,a,a); 8:write{b,a,a,a); 9:write{a,f); end; end; procedure unite(nb:integer); var a,b, f:char; begin a: =’I’ ; b: =’V’ ; f: =’X’; convers(nb,a,b,f); end; procedure dizaine(nb:integer); var a,b,f:char; begin a:='X'; b:='L'; f :='C'; convers(nb,a,b,f); end; procedure centaine(nb:integer); var a,b,f:char; begin a:='C'; b:='D'; f:='M' ; convers(nb,a,b,f); end; procedure mille(nb:integer); var a:char; begin a: ='M' ; convers(nb,a,b,f); end; begin writeln('Entrez le nombre entier a convertir'); read (nb); if O>nb then writeln('l operation est impossible'); if 4000<=nb then writeln('l operation est impossible'); if (l<-nb) and (nb<10) then unite(nb) else if(l0<=nb)and(nb<100) then begin dizaine(nb); unite (nb) ; end ; else if (100<=nb) and (nb<1000) then begin r:=nb div 100; r:=centaine(nb); g:=:nb mod 100; s:=g div 10 ; g:= dizaine(nb); q:=s mod 10; q:=unite(nb); end else if (lOOO<=nb)and(nb<3999) then begin e:=nb div 1000; e:= mille (nb) ; h:=nb mod 1000; n:= h div 100; n:= centaine(nb); j:=h mod 100; t:=j div 10; t:= dizaine(nb) ; w:=j mod 10; w:= unite(nb); end; end. [/align]

انتظر رايكم وتصحيح الأخطاء
والسلام عليكم
الرد
#2
مثال:
PHP كود :
function DecToRoman(Decimal: Longint): string;
const
  
Numbers: array[1..13] of Integer =
    (
1, 4, 5, 9, 10, 40, 50, 90, 100,
    
400, 500, 900, 1000);
  
Romans: array[1..13] of string =
    (
'I', 'IV', 'V', 'IX', 'X', 'XL',
    
'L', 'XC', 'C', 'CD', 'D', 'CM', 'M');
var
  
i: Integer;
begin
  Result 
:= '';
  for 
i := 13 downto 1 do
    while (
Decimal >= Numbers[i]) do
    
begin
      Decimal 
:= Decimal - Numbers[i];
      
Result  := Result + Romans[i];
    
end;
end;


//Example:

procedure TForm1.Button1Click(Sender: TObject);
begin
  label1
.Caption := DecToRoman(5);
  
Label2.Caption := DecToRoman(458);
end; 
الرد
#3

شكرا وبارك الله فيك

الرد


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


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