procedure get_num(var m: bignum; var n: integer); var i := 0; s: string; begin write('Введите число = '); readln(s); s := trim(s); n := 0; for i := length(s) downto 1 do if s[i] in ['0'..'9'] then begin n := n + 1; m[n] := strtoint(s[i]); end; end;
function more(a, b: bignum; n_a: integer): boolean; var i: integer; f := false; begin for i := n_a downto 1 do begin if a[i] > b[i] then f := true else if a[i] < b[i] then f := false; if a[i] <> b[i] then break; end; more := f; end;
procedure show(m: bignum; n: integer); var i: integer; begin write('Вывод '); for i := n downto 1 do write(m[i]); writeln(); end;
begin get_num(a, n_a); get_num(b, n_b);
while (n_a >= n_b) and more(a, b, n_a) do begin if (a[n_a] > b[n_b]) then k := n_a - n_b else if n_a > n_b then k := n_a - n_b - 1 else k := 0;
for i := 1 to n_b do begin a[i + k] := a[i + k] - b[i]; if a[i + k] < 0 then begin for j := i + k to n_a - 1 do begin if a[j] >= 0 then break; a[j] := a[j] + 10; a[j + 1] := a[j + 1] - 1; end end; end; if a[n_a] = 0 then n_a := n_a - 1; end;
Program Task; Const N = 5; Var a: Array [1..N] of LongInt; i: Integer; Function MinDigit(number: LongInt): Integer; Var digits: Array of Integer; num, min, i: Integer; Begin num := number; While num <> 0 Do Begin num := num Div 10; i := i + 1; End; SetLength(digits, i); num := number; For i := 0 To Length(digits) - 1 Do Begin digits[i] := num Mod 10; num := num Div 10;End; For i := 0 To Length(digits) - 1 Do If digits[i] < digits[min] Then min := i; Result := digits[min]; End; Begin WriteLn('Введите ', N, ' целых чисел через пробел'); For i := 1 To N Do Read(a[i]); For i := 1 To N Do Write(MinDigit(a[i]), ' '); End.
bignum = array[1..100] of integer;
var
a, b: bignum;
i, j, k, n_a, n_b: integer;
procedure get_num(var m: bignum; var n: integer);
var
i := 0;
s: string;
begin
write('Введите число = ');
readln(s);
s := trim(s);
n := 0;
for i := length(s) downto 1 do
if s[i] in ['0'..'9'] then begin
n := n + 1;
m[n] := strtoint(s[i]);
end;
end;
function more(a, b: bignum; n_a: integer): boolean;
var
i: integer;
f := false;
begin
for i := n_a downto 1 do
begin
if a[i] > b[i] then f := true
else if a[i] < b[i] then f := false;
if a[i] <> b[i] then break;
end;
more := f;
end;
procedure show(m: bignum; n: integer);
var
i: integer;
begin
write('Вывод ');
for i := n downto 1 do
write(m[i]);
writeln();
end;
begin
get_num(a, n_a);
get_num(b, n_b);
while (n_a >= n_b) and more(a, b, n_a) do
begin
if (a[n_a] > b[n_b]) then k := n_a - n_b
else if n_a > n_b then k := n_a - n_b - 1
else k := 0;
for i := 1 to n_b do
begin
a[i + k] := a[i + k] - b[i];
if a[i + k] < 0 then begin
for j := i + k to n_a - 1 do
begin
if a[j] >= 0 then break;
a[j] := a[j] + 10;
a[j + 1] := a[j + 1] - 1;
end
end;
end;
if a[n_a] = 0 then n_a := n_a - 1;
end;
show(a, n_a);
end.
Const N = 5;
Var a: Array [1..N] of LongInt;
i: Integer;
Function MinDigit(number: LongInt): Integer;
Var digits: Array of Integer;
num, min, i: Integer;
Begin
num := number;
While num <> 0 Do
Begin
num := num Div 10;
i := i + 1;
End;
SetLength(digits, i);
num := number;
For i := 0 To Length(digits) - 1 Do
Begin
digits[i] := num Mod 10;
num := num Div 10;End;
For i := 0 To Length(digits) - 1 Do
If digits[i] < digits[min] Then
min := i; Result := digits[min];
End;
Begin
WriteLn('Введите ', N, ' целых чисел через пробел');
For i := 1 To N Do
Read(a[i]);
For i := 1 To N Do
Write(MinDigit(a[i]), ' ');
End.