Como hacer este ejercicio de pascal
{Esto seria una forma de realizar lo como apoyo a tu trabajo}
program mulrusa;
uses
crt, dos;
var
mul1, mul2 : integer;
total, res1, res2 : longint;
tecla : char;
resulmul1 : array[0..100] of integer;
resulmul2 : array[0..100] of integer;
function stringinteger(s : string) : integer;
var
r : integer;
er : integer;
begin
val(s,r,er);
stringinteger := r;
end;
procedure entrada_numeros;
var
dato : string[10];
entra, i : integer;
begin
i := 1;
entra := 1;
repeat
if entra = 1 then
begin
TextBackground(0);
gotoxy(3,2);ClrEol;
textcolor(1);
TextBackground(7);
gotoxy(3,2);write(' Entre Multiplicador :');
gotoxy(28,2);
end;
if entra = 2 then
begin
TextBackground(0);
gotoxy(3,2);ClrEol;
textcolor(15);
TextBackground(1);
gotoxy(3,2);write(' Entre Multiplicando :');
gotoxy(28,2);
end;
fillchar(dato,11,' ');
dato[0] := chr(10);
repeat
tecla := readkey;
if tecla in[#48..#57] then
begin
dato[i] := tecla;
dato[0] := chr(i);
gotoxy(28,2);write(dato);
i := i + 1;
if i > 10 then
i := 10;
end;
if tecla = #8 then
begin
i := i - 1;
dato[i] := ' ';
dato[0] := chr(i);
gotoxy(28,2);write(dato);
end;
until tecla = #13;
if entra = 1 then
begin
mul1 := stringinteger(dato);
end;
if entra = 2 then
begin
mul2 := stringinteger(dato);
end;
entra := entra + 1;
until entra > 2;
TextBackground(0);
gotoxy(3,2);ClrEol;
textcolor(10);
TextBackground(7);
writeln('La operacion Sera = ',mul1,' X ',mul2);
textcolor(15);
TextBackground(0);
end;
procedure proceso_multiplicacion_rusa(multp, multd : integer);
var
co, resul1, resul2 : longint;
res : real;
cont : integer;
begin
co := 0;
resulmul1[co] := multp;
resulmul2[co] := multd;
resul1 := 0;
resul2 := 0;
co := 1;
res := 0.0;
repeat
res := (multp / 2);
resul1 := round(int(res));
resul2 := multd * 2;
if resul1 > 0 then
begin
resulmul1[co] := resul1;
resulmul2[co] := resul2;
multp := resul1;
multd := resul2;
co := co + 1;
end;
until resul1 <= 0;
resul1 := 0;
resul2 := 0;
for cont := 0 to (co - 1) do
begin
if Frac(resulmul1[cont] / 2) = 0 then
begin
resulmul1[cont] := 0;
resulmul2[cont] := 0;
end;
end;
writeln;
total := 0;
for cont := 0 to (co - 1) do
begin
if resulmul1[cont] > 0 then
begin
total := total + resulmul2[cont];
end;
end;
gotoxy(3,2);ClrEol;
writeln('La operacion de la Multiplicar Rusa sera = ',mul1,' X ',mul2,' = ',total);
end;
begin
clrscr;
textcolor(15);
entrada_numeros;
proceso_multiplicacion_rusa(mul1, mul2);
readln;
end.
{Suerte}