1)
var
a, b, s : real;
begin
read (a, b);
s := a * b;
write (s:10:4);
end.
2)
var
a, b, c, k : integer;
begin
read (a, b, c);
k := 0;
if a > 0 then inc (k);
if b > 0 then inc (k);
if c > 0 then inc (k);
writeln (k);
end.
3)
var
a : integer;
begin
read (a);
writeln ((a mod 10) * (a mod 100 div 10) * (a div 100 mod 10) * (a div 1000));
end.
4)
var
c, n : integer;
begin
read (n);
c := 0;
repeat
inc (c);
n := n div 10;
until n = 0;
writeln (c);
end.
5)
var
n, sum, i : integer;
begin
read (n);
sum := 0;
for i := 1 to n do
sum := sum + i;
writeln (sum);
end.
6)
var
d, n, k : integer;
begin
read (n, k);
d := 0;
while n >= k do
begin
d := d + 1;
n := n - k;
end;
writeln ('n div k = ', d);
writeln ('n mod k = ', n);
end.
7)
var
n, sum, i, tmp : integer;
begin
read (n);
sum := 0;
for i := 1 to n do
begin
read (tmp);
sum := sum + tmp;
end;
writeln (sum / n);
end.
8)
var
i, n, s : integer;
a : array [1..1000] of integer;
begin
s := 2;
read (n);
for i := 1 to n do
begin
a[i] := s;
s := s + 2 * i + 1;
end;
for i := 1 to n do write (a[i], ' ');
end.
9)
var
n, i, count, tmp : integer;
begin
read (n);
count := 0;
for i := 1 to n do
begin
read (tmp);
if tmp < 0 then inc (count);
end;
writeln (count);
end.
10)
var
n, i, j : integer;
begin
read (n);
for i := 1 to n do
begin
for j := 1 to i do
write ('*');
writeln;
end;
end.
11) //Не понял, как заполняется массив? Тут рандом
var
a : array [1..1000] of integer;
i, n : integer;
begin
read (n);
for i := 1 to n do
a[i] := trunc (random (1000)) - 500;
for i := 1 to n do
if a[i] > 0 then a[i] := a[i] * (-1)
else if a[i] < 0 then a[i] := sqr (a[i]);
for i := 1 to n do
write (a[i], ' ');
end.
12)
var
n, i, count : integer;
begin
read (n);
count := 0;
for i := 1 to n do
if n mod i = 0 then inc (count);
writeln (count);
end.
Объяснение:
1. 10100111₂=1·2⁷+0·2⁶+1·2⁵+0·2⁴+0·2³+1·2²+1·2¹+1·2⁰=128+32+4+2+1=167₁₀
ответ: 167.
2. 10101010₂=1·2⁷+0·2⁶+1·2⁵+0·2⁴+1·2³+0·2²+1·2¹+0·2⁰=128+32+8+2=170₁₀
242₈=2·8²+4·8¹+2·8⁰=128+32+2=162₁₀
4₁₆=4·16⁰=4₁₀
10101010₂-242₈+4₁₆=170₁₀-162₁₀+4₁₀=12₁₀
ответ: 12.
3. 101011₂=1·2⁵+0·2⁴+1·2³+0·2²+1·2¹+1·2⁰=32+8+2+1=43₁₀
250₈=2·8²+5·8¹+0·8⁰=128+40=168₁₀
716₈=7·8²+1·8¹+6·8⁰=448+8+6=462₁₀
101011₂+250₈+716₈=43₁₀+168₁₀+462₁₀=673₁₀
ответ: 673.
4. 10101011₂=1·2⁷+0·2⁶+1·2⁵+0·2⁴+1·2³+0·2²+1·2¹+1·2⁰=128+32+8+2+1=171₁₀
250₈=2·8²+5·8¹+0·8⁰=128+40=168₁₀
5₁₆=5·16⁰=5₁₀
10101011₂-250₈+5₁₆=171₁₀-168₁₀+5₁₀=8₁₀
ответ: 8.