1. uses crt; const n=20; var i,cp1,cn1:integer; p,cp,cn:real; z:array[1..n] of integer; begin randomize; for i:=1 to n do begin z[i]:=random(20,-20); if z[i]>=0 then begin cp:=cp+z[i]; cp1:=cp1+1; end else begin cn:=cp+z[i]; cn1:=cn1+1; end; cp:=cp/cp1; cn:=cn/cn1; end; if cp>cn then p:=cp+cn else p:=cp*cn; for i:=1 to n do write(z[i],' '); writeln(#13#10,cp:5:2,' ',cn:5:2,' ',p:5:2); end. 2. uses crt; const n=15;m=4; var i,j,k,flag,count:integer; a:array[1..n,1..m] of integer; temp:array[1..100] of integer; b:array[1..100,1..m] of integer; begin randomize; k:=1; count:=0; for i:=1 to n do begin flag:=1; for j:=1 to m do begin a[i,j]:=random(51,1); if (a[i,j]<10) or (a[i,j]>40) then flag:=0 end; if flag=1 then begin temp[k]:=i; count:=count+1; k:=k+1; end; end; for i:=1 to count do for j:=1 to m do b[i,j]:=a[temp[i],j]; writeln('Массив A:'); for i:=1 to n do begin for j:=1 to m do write(a[i,j],' '); write(#13#10); end; if count=0 then writeln('Нет подходящих строк.') else begin writeln(#13#10,'Массив B:'); for i:=1 to count do begin for j:=1 to m do write(b[i,j],' '); write(#13#10); end; end; end.
#include <iostream>
using namespace std;
int k=2;
bool StrangeSeq(int n){
if (k<n){
if(n%k==0){
cout<<"false";
return false;
}
k++;
StrangeSeq(n);
}
else
{
cout<<"true";
return true;
}
}
int main(){
int n;
cin>>n;
StrangeSeq(n);
cin.get();
cin.get();
}
uses crt;
const n=20;
var i,cp1,cn1:integer;
p,cp,cn:real;
z:array[1..n] of integer;
begin
randomize;
for i:=1 to n do
begin
z[i]:=random(20,-20);
if z[i]>=0 then
begin
cp:=cp+z[i];
cp1:=cp1+1;
end
else
begin
cn:=cp+z[i];
cn1:=cn1+1;
end;
cp:=cp/cp1;
cn:=cn/cn1;
end;
if cp>cn then
p:=cp+cn
else
p:=cp*cn;
for i:=1 to n do
write(z[i],' ');
writeln(#13#10,cp:5:2,' ',cn:5:2,' ',p:5:2);
end.
2.
uses crt;
const n=15;m=4;
var i,j,k,flag,count:integer;
a:array[1..n,1..m] of integer;
temp:array[1..100] of integer;
b:array[1..100,1..m] of integer;
begin
randomize;
k:=1;
count:=0;
for i:=1 to n do
begin
flag:=1;
for j:=1 to m do
begin
a[i,j]:=random(51,1);
if (a[i,j]<10) or (a[i,j]>40) then
flag:=0
end;
if flag=1 then
begin
temp[k]:=i;
count:=count+1;
k:=k+1;
end;
end;
for i:=1 to count do
for j:=1 to m do
b[i,j]:=a[temp[i],j];
writeln('Массив A:');
for i:=1 to n do
begin
for j:=1 to m do
write(a[i,j],' ');
write(#13#10);
end;
if count=0 then
writeln('Нет подходящих строк.')
else
begin
writeln(#13#10,'Массив B:');
for i:=1 to count do
begin
for j:=1 to m do
write(b[i,j],' ');
write(#13#10);
end;
end;
end.