Const N = 7; // количество наименований товаров Var A:array[1..N,1..3] of integer; i,k,S:integer; Begin For i:= 1 to N do Read(A[i,1],A[i,2],A[i,3]); k:=0; For i:= N downto 1 do if A[i,2] = 0 then k:=i; if k > 0 then Begin Write('00 - ',A[k,1]*A[k,3]); S:=0; For i:= k+1 to N do if A[i,2] = 0 then Begin Write('+',A[i,1]*A[i,3]); S:=S+A[i,1]*A[i,3]; End; if S <> 0 then Write('=',S+A[k,1]*A[k,3]); WriteLn; End; k:=0; For i:= N downto 1 do if A[i,2] = 1 then k:=i; if k > 0 then Begin Write('01 - ',A[k,1]*A[k,3]); S:=0; For i:= k+1 to N do if A[i,2] = 1 then Begin Write('+',A[i,1]*A[i,3]); S:=S+A[i,1]*A[i,3]; End; if S <> 0 then Write('=',S+A[k,1]*A[k,3]); WriteLn; End; k:=0; For i:= N downto 1 do if A[i,2] = 10 then k:=i; if k > 0 then Begin Write('10 - ',A[k,1]*A[k,3]); S:=0; For i:= k+1 to N do if A[i,2] = 10 then Begin Write('+',A[i,1]*A[i,3]); S:=S+A[i,1]*A[i,3]; End; if S <> 0 then Write('=',S+A[k,1]*A[k,3]); WriteLn; End; k:=0; For i:= N downto 1 do if A[i,2] = 11 then k:=i; if k > 0 then Begin Write('11 - ',A[k,1]*A[k,3]); S:=0; For i:= k+1 to N do if A[i,2] = 11 then Begin Write('+',A[i,1]*A[i,3]); S:=S+A[i,1]*A[i,3]; End; if S <> 0 then Write('=',S+A[k,1]*A[k,3]); WriteLn; End; End.
//PascalABC.NET (версия 3.1, сборка 1196 от 09.03.2016) function Transpose(a: array[,] of integer): array[,] of integer; //Поворот на 90гр по часовой стрелке begin var m := Length(a, 0); var n := Length(a, 1); Result := new integer[n, m]; for var i := 0 to n-1 do begin for var j := 0 to m-1 do Result[i, j] := a[m-1-j, i]; end; end;
begin var n := ReadInteger('Введите n:'); //Заполнение матрицы NxN сл. числами и вывод на экран var a :=MatrixRandom(n, n); for var i:=0 to n-1 do begin for var j:=0 to n-1 do Print(a[i,j]); println; end; println;
Println('поворот влево на 90 гр'); var b := Transpose(a); b:=Transpose(b); b:=Transpose(b); for var i:=0 to n-1 do begin for var j:=0 to n-1 do Print(b[i,j]); println; end; println;
Println('поворот вправо на 90гр'); b := Transpose(a); for var i:=0 to n-1 do begin for var j:=0 to n-1 do Print(b[i,j]); println; end; println;
Println('поворот на 180 гр'); b := Transpose(a); b := Transpose(b); for var i:=0 to n-1 do begin for var j:=0 to n-1 do Print(b[i,j]); println; end; end.
N = 7; // количество наименований товаров
Var
A:array[1..N,1..3] of integer;
i,k,S:integer;
Begin
For i:= 1 to N do
Read(A[i,1],A[i,2],A[i,3]);
k:=0;
For i:= N downto 1 do
if A[i,2] = 0 then k:=i;
if k > 0 then
Begin
Write('00 - ',A[k,1]*A[k,3]);
S:=0;
For i:= k+1 to N do
if A[i,2] = 0 then
Begin
Write('+',A[i,1]*A[i,3]);
S:=S+A[i,1]*A[i,3];
End;
if S <> 0 then Write('=',S+A[k,1]*A[k,3]);
WriteLn;
End;
k:=0;
For i:= N downto 1 do
if A[i,2] = 1 then k:=i;
if k > 0 then
Begin
Write('01 - ',A[k,1]*A[k,3]);
S:=0;
For i:= k+1 to N do
if A[i,2] = 1 then
Begin
Write('+',A[i,1]*A[i,3]);
S:=S+A[i,1]*A[i,3];
End;
if S <> 0 then Write('=',S+A[k,1]*A[k,3]);
WriteLn;
End;
k:=0;
For i:= N downto 1 do
if A[i,2] = 10 then k:=i;
if k > 0 then
Begin
Write('10 - ',A[k,1]*A[k,3]);
S:=0;
For i:= k+1 to N do
if A[i,2] = 10 then
Begin
Write('+',A[i,1]*A[i,3]);
S:=S+A[i,1]*A[i,3];
End;
if S <> 0 then Write('=',S+A[k,1]*A[k,3]);
WriteLn;
End;
k:=0;
For i:= N downto 1 do
if A[i,2] = 11 then k:=i;
if k > 0 then
Begin
Write('11 - ',A[k,1]*A[k,3]);
S:=0;
For i:= k+1 to N do
if A[i,2] = 11 then
Begin
Write('+',A[i,1]*A[i,3]);
S:=S+A[i,1]*A[i,3];
End;
if S <> 0 then Write('=',S+A[k,1]*A[k,3]);
WriteLn;
End;
End.
Пример работы программы:
17 1 2
3 0 5
7 1 4
8 11 9
95 0 3
31 10 44
5 1 6
00 - 15+285=300
01 - 34+28+30=92
10 - 1364
11 - 72
function
Transpose(a: array[,] of integer): array[,] of integer;
//Поворот на 90гр по часовой стрелке
begin
var m := Length(a, 0);
var n := Length(a, 1);
Result := new integer[n, m];
for var i := 0 to n-1 do begin
for var j := 0 to m-1 do
Result[i, j] := a[m-1-j, i];
end;
end;
begin
var n := ReadInteger('Введите n:');
//Заполнение матрицы NxN сл. числами и вывод на экран
var a :=MatrixRandom(n, n);
for var i:=0 to n-1 do begin
for var j:=0 to n-1 do
Print(a[i,j]);
println;
end;
println;
Println('поворот влево на 90 гр');
var b := Transpose(a);
b:=Transpose(b);
b:=Transpose(b);
for var i:=0 to n-1 do begin
for var j:=0 to n-1 do
Print(b[i,j]);
println;
end;
println;
Println('поворот вправо на 90гр');
b := Transpose(a);
for var i:=0 to n-1 do begin
for var j:=0 to n-1 do
Print(b[i,j]);
println;
end;
println;
Println('поворот на 180 гр');
b := Transpose(a);
b := Transpose(b);
for var i:=0 to n-1 do begin
for var j:=0 to n-1 do
Print(b[i,j]);
println;
end;
end.