//PascalABC.NET 3.1 сборка 1219 procedure PrintMatrix(a: array[,] of integer); begin for var i := a.GetLowerBound(0) to a.GetUpperBound(0) do begin writeln; for var j := a.GetLowerBound(1) to a.GetUpperBound(1) do write(a[i, j], ' '); end; writeln; end;
begin var a := MatrixRandom(9, 9, 10, 99); PrintMatrix(a); var i := (a.GetLowerBound(0) + a.GetUpperBound(0)) div 2 + (a.GetLowerBound(0) + a.GetUpperBound(0)) mod 2; var j := (a.GetLowerBound(1) + a.GetUpperBound(1)) div 2 + (a.GetLowerBound(1) + a.GetUpperBound(1)) mod 2; writeln('A[', i, ', ', j, '] = ', a[i, j]); end.
Var m : array[0..6] of Integer; i,k,N : Integer; Begin For i:=0 to 6 do m[i]:=0; Readln(N); k:=6; While N>0 do Begin If N>=Power(2,k) then Begin N:=N-Trunc(Power(2,k)); Inc(m[k]); end else Dec(k); end; For i:=0 to 6 do Writeln(Power(2,i),' ',m[i],' шт.'); end.
Еще вариант: Const NN = 7; money : array[1..7] of Integer = (1,2,4,8,16,32,64); Var m : array[1..NN] of Integer; i,k,N : Integer; Begin For i:=1 to NN do m[i]:=0; Readln(N); k:=NN; While N>0 do Begin If N>=money[k] then Begin N:=N-money[k]; Inc(m[k]); end else Dec(k); end; For i:=1 to NN do Writeln(money[i],' ',m[i],' шт.'); end.
procedure PrintMatrix(a: array[,] of integer);
begin
for var i := a.GetLowerBound(0) to a.GetUpperBound(0) do
begin
writeln;
for var j := a.GetLowerBound(1) to a.GetUpperBound(1) do
write(a[i, j], ' ');
end;
writeln;
end;
begin
var a := MatrixRandom(9, 9, 10, 99);
PrintMatrix(a);
var i := (a.GetLowerBound(0) + a.GetUpperBound(0)) div 2 + (a.GetLowerBound(0) + a.GetUpperBound(0)) mod 2;
var j := (a.GetLowerBound(1) + a.GetUpperBound(1)) div 2 + (a.GetLowerBound(1) + a.GetUpperBound(1)) mod 2;
writeln('A[', i, ', ', j, '] = ', a[i, j]);
end.
i,k,N : Integer;
Begin
For i:=0 to 6 do m[i]:=0;
Readln(N);
k:=6;
While N>0 do
Begin
If N>=Power(2,k) then
Begin
N:=N-Trunc(Power(2,k));
Inc(m[k]);
end else Dec(k);
end;
For i:=0 to 6 do Writeln(Power(2,i),' ',m[i],' шт.');
end.
Еще вариант:
Const
NN = 7;
money : array[1..7] of Integer = (1,2,4,8,16,32,64);
Var m : array[1..NN] of Integer;
i,k,N : Integer;
Begin
For i:=1 to NN do m[i]:=0;
Readln(N);
k:=NN;
While N>0 do
Begin
If N>=money[k] then
Begin
N:=N-money[k];
Inc(m[k]);
end else Dec(k);
end;
For i:=1 to NN do Writeln(money[i],' ',m[i],' шт.');
end.