1) uses crt; var a:array [1..15] of integer; i,k:integer; begin randomize; k:=0; for i:=1 to 15 do begin a[i]:=random(10)-3; if (a[i]<0) then inc(k); write (a[i],' '); end; writeln; writeln (k/15*100,'%'); end.
2) uses crt; var a:array [1..20] of integer; i:integer; begin randomize; for i:=1 to 20 do begin a[i]:=random(30); write (a[i],' '); end; writeln; for i:=1 to 20 do if (a[i] mod 10 = 3) then write (a[i],' '); end.
3) uses crt; var a:array [1..20] of integer; i:integer; k:longint; begin randomize; k:=1; for i:=1 to 20 do begin a[i]:=random(30); write (a[i],' '); if (a[i]>9) and (a[i]<100) then k:=k*a[i]; end; writeln; writeln (k); end.
4) uses crt; var a:array [1..30] of integer; i:integer; flag:boolean; begin randomize; for i:=1 to 30 do begin a[i]:=random(30); write (a[i],' '); end; writeln; flag:=true; for i:=1 to 29 do if (a[i]>a[i+1]) then begin flag:=false; break; end; writeln (flag); end.
int main() { int A[15] = {1,2,3,-1,-2,-3,1,2,-1,-2,1,2,3,4,5}; int k = 0; for (int i=0; i<15; i++) k+=(A[i]<0) ? 1:0; std::cout <<(k/15*100) <<'\n'; return 0; }
2) #include <iostream>
int main() { int A[20] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,33,20}; for (int i=0; i<20; i++) if (A[i]%10==3) std::cout <<A[i] <<std::endl; return 0; }
3) #include <iostream>
int main() { int A[13] = {1,2,3,4,5,6,7,8,9,10,11,12,13}; usnigned int p = 1; for (int i=0; i<13; i++) p*=(A[i]>9 && A[i]<100) ? A[i]:1; std::cout <<p <<'\n'; return 0; }
4) #include <iostream>
int main() { int A[30] = {1,2,3,4,5,6,7,8,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22, 23 24 25 26,27,28,29,28}; bool flag = true; for (int i=0; i<29; i++) if (a[i]>a[i+1]) { flag = false; break; } std::cout <<std::boolalpha <<flag <<std::endl; return 0; }
uses crt;
var a:array [1..15] of integer;
i,k:integer;
begin
randomize;
k:=0;
for i:=1 to 15 do
begin
a[i]:=random(10)-3;
if (a[i]<0) then inc(k);
write (a[i],' ');
end;
writeln;
writeln (k/15*100,'%');
end.
2)
uses crt;
var a:array [1..20] of integer;
i:integer;
begin
randomize;
for i:=1 to 20 do
begin
a[i]:=random(30);
write (a[i],' ');
end;
writeln;
for i:=1 to 20 do
if (a[i] mod 10 = 3) then write (a[i],' ');
end.
3)
uses crt;
var a:array [1..20] of integer;
i:integer;
k:longint;
begin
randomize;
k:=1;
for i:=1 to 20 do
begin
a[i]:=random(30);
write (a[i],' ');
if (a[i]>9) and (a[i]<100) then k:=k*a[i];
end;
writeln;
writeln (k);
end.
4)
uses crt;
var a:array [1..30] of integer;
i:integer;
flag:boolean;
begin
randomize;
for i:=1 to 30 do
begin
a[i]:=random(30);
write (a[i],' ');
end;
writeln;
flag:=true;
for i:=1 to 29 do
if (a[i]>a[i+1]) then
begin
flag:=false;
break;
end;
writeln (flag);
end.