Const CSize1=7; CSize2=6; CSize3=5; type TMas1=array[1..CSize1,1..CSize1] of integer; TMas2=array[1..Csize2, 1..CSize2] of integer; TMas3=array[1..Csize3, 1..CSize3] of integer;
var A1:TMas1; A2:TMas2; A3:TMas3; i,j,x, y:byte;
function zero(i:integer):boolean; begin zero:=false; if i=0 then zero:=true; end;
function interval(i:integer):boolean; begin interval:=false; if (i<=12) and (i>=1) then interval:=true; end;
begin X:=0; Y:=0; randomize; for i:=1 to CSize1 do begin for j:=1 to CSize1 do begin A1[i, j]:=random(50); write(A1[i, j]:3); if zero(A1[i, j]) then inc(x); if interval(A1[i,j]) then inc(y); end; writeln; end; writeln('Kol-vo 0 =', x); writeln('Kol-vo v intervale=', y); writeln; x:=0; y:=0; for i:=1 to CSize2 do begin for j:=1 to CSize2 do begin A2[i, j]:=random(50); write(A2[i,j]:3); if zero(A1[i,j]) then inc(x); if interval(A2[i,j]) then inc(y); end; writeln; end; writeln('Kol-vo 0 =', x); writeln('Kol-vo v intervale=', y); writeln; x:=0; y:=0; for i:=1 to CSize3 do begin for j:=1 to CSize3 do begin A3[i, j]:=random(50); write(A3[i,j]:3); if zero(A3[i,j]) then inc(x); if interval(A3[i,j]) then inc(y); end; writeln; end; writeln('Kol-vo 0 =', x); writeln('Kol-vo v intervale=', y); writeln; x:=0; y:=0; end.
CSize2=6;
CSize3=5;
type TMas1=array[1..CSize1,1..CSize1] of integer;
TMas2=array[1..Csize2, 1..CSize2] of integer;
TMas3=array[1..Csize3, 1..CSize3] of integer;
var A1:TMas1;
A2:TMas2;
A3:TMas3;
i,j,x, y:byte;
function zero(i:integer):boolean;
begin
zero:=false;
if i=0 then zero:=true;
end;
function interval(i:integer):boolean;
begin
interval:=false;
if (i<=12) and (i>=1) then interval:=true;
end;
begin
X:=0;
Y:=0;
randomize;
for i:=1 to CSize1 do
begin
for j:=1 to CSize1 do
begin
A1[i, j]:=random(50);
write(A1[i, j]:3);
if zero(A1[i, j]) then inc(x);
if interval(A1[i,j]) then inc(y);
end;
writeln;
end;
writeln('Kol-vo 0 =', x);
writeln('Kol-vo v intervale=', y);
writeln;
x:=0;
y:=0;
for i:=1 to CSize2 do
begin
for j:=1 to CSize2 do
begin
A2[i, j]:=random(50);
write(A2[i,j]:3);
if zero(A1[i,j]) then inc(x);
if interval(A2[i,j]) then inc(y);
end;
writeln;
end;
writeln('Kol-vo 0 =', x);
writeln('Kol-vo v intervale=', y);
writeln;
x:=0;
y:=0;
for i:=1 to CSize3 do
begin
for j:=1 to CSize3 do
begin
A3[i, j]:=random(50);
write(A3[i,j]:3);
if zero(A3[i,j]) then inc(x);
if interval(A3[i,j]) then inc(y);
end;
writeln;
end;
writeln('Kol-vo 0 =', x);
writeln('Kol-vo v intervale=', y);
writeln;
x:=0;
y:=0;
end.
#include <iostream>
using namespace std;
int main() {
setlocale(LC_ALL, "");
int N = 10;
int max = -9999999;
int sum = 0;
int choise = 0;
int arr[N] = {0};
cout << "Введите 10 значений: ";
for(int i = 0; i<N; ++i) {
cin >> arr[i];
}
cout << "Введите действие (1 - +, 2 - макс. значение, 3 - колво отр. значений)";
cin >> choise;
if(choise==1) {
for(int i = 0; i<N; ++i) {
sum+=arr[i];
}
cout << endl << "Сумма: " << sum;
}
if(choise==2) {
for(int i = 0; i<N; ++i) {
if(arr[i]>max) {
max = arr[i];
}
}
cout << endl << "Макс. знач: " << max;
}
if(choise==3) {
for(int i = 0; i<N; ++i) {
if(arr[i]<0) {
++sum;
}
}
cout << "Колво отр. знач: " << sum;
}
if(choise!=1&&choise!=2&&choise!=3) {
cout << "Введите корректное значение.";
}
return 0;
}