Const N = 3; Var A:Array[1..N,1..N] of integer; i,j:integer; Begin Randomize; WriteLn('Исходный массив:'); For i:= 1 to N do Begin For j:= 1 to N do Begin A[i,j]:=random(21)-10; Write(A[i,j]:3,' ') End; WriteLn End; WriteLn; WriteLn('Переработанный массив:'); For i:= 1 to N do Begin For j:= 1 to N do Begin if A[i,j]>0 then A[i,j]:=A[i,j]*A[i,j]; Write(A[i,j]:3,' '); End; WriteLn End; End.
N = 3;
Var
A:Array[1..N,1..N] of integer;
i,j:integer;
Begin
Randomize;
WriteLn('Исходный массив:');
For i:= 1 to N do
Begin
For j:= 1 to N do
Begin
A[i,j]:=random(21)-10;
Write(A[i,j]:3,' ')
End;
WriteLn
End;
WriteLn;
WriteLn('Переработанный массив:');
For i:= 1 to N do
Begin
For j:= 1 to N do
Begin
if A[i,j]>0 then A[i,j]:=A[i,j]*A[i,j];
Write(A[i,j]:3,' ');
End;
WriteLn
End;
End.
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int a[n][m];
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++) {
cin >> a[i][j];
if(a[i][j] > 0) a[i][j]*=a[i[j];
}
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++)
cout << a[i][j] << " ";
cout << endl;
}
}