var m,n,i,j:integer; s:longint; a:array[1..mm,1..nn] of integer;
begin Randomize; Read(m,n); s:=0; for i:=1 to m do begin for j:=1 to n do begin a[i,j]:=Random(101)-50; Write(a[i,j]:4); s:=a[i,j]*Sqr(a[i,j]) end; Writeln end; Writeln('Сумма кубов равна ',s) end.
#include <stdio.h>
#include <conio.h>
#include <time.h>
#include <stdlib.h>
#include <math.h>
#define N 5
#define M 10
int main(){ int a[N][M],i,j,Sum=0;
srand((unsigned)time(NULL));
for (i=0;i<N;i++){
for(j=0;j<M;j++){
a[i][j]=rand()%10+1;
} };
for (i=0;i<N;i++){
for(j=0;j<M;j++){
Sum=pow(a[i][j],3)+Sum;
} };
printf("%d",Sum);
getch ();
return 0;
}
nn=30;
mm=30;
var
m,n,i,j:integer;
s:longint;
a:array[1..mm,1..nn] of integer;
begin
Randomize;
Read(m,n);
s:=0;
for i:=1 to m do begin
for j:=1 to n do begin
a[i,j]:=Random(101)-50;
Write(a[i,j]:4);
s:=a[i,j]*Sqr(a[i,j])
end;
Writeln
end;
Writeln('Сумма кубов равна ',s)
end.
Пример
4 5
21 -47 -14 -24 -40
34 -49 45 -21 -49
-34 -21 25 41 -46
-44 49 -10 2 14
Сумма кубов равна 2744