code: with text_io; use text_io; procedure mult_russ is package entier_es is new text_io.integer_io(integer); use entier_es; a, b : integer; min, max, p : integer; begin put("donner la valeur de a : "); get(a); put("donner la valeur de b : "); get(b); if (a>b) then max := a; min := b; else max := b; min := a; end if; p := 0; while (min /= 1) loop if ((min mod 2) = 1) then p := p + max; end if; min := min / 2; max := 2 * max; end loop; p := p + max; new_line; put("a * b = "); put(p); end mult_russ; |
Histoire de ressusciter le Forum :-?
Code:
Multiplications.ads
quote: With Ada.Text_IO, Ada.Integer_Text_IO; package Multiplications is package ES_Mes_Entiers is new Ada.Text_IO.Integer_IO(Integer); Use ES_Mes_Entiers; procedure MultiRusse; end Multiplications; |
quote: With Ada.Text_IO; Use Ada.Text_IO; package body Multiplications is procedure MultiRusse is A, B : Integer; Min, Max, P : Integer; begin Put_line("Donnez la valeur de A:"); Put(">");Get(A);Skip_Line; Put_line("Donnez la valeur de B:"); Put(">");Get(B);Skip_line; if(A > B) then Max := A; Min := B; else Max := B; Min := A; end if; P := 0; while(Min /= 1) loop if( (Min mod 2) = 1) then P := P + Max; end if; Min := Min / 2; Max := 2 * Max; end loop; P := P + Max; New_Line; Put("A * B = ");Put(P, 2); end MultiRusse; end Multiplications; |
quote: With Multiplications; Use Multiplications; procedure Main is begin MultiRusse; end Main; |