1) var n:integer; begin readln(n); if(n<0)then write(0) else write(n+4); end.
2) var a, b: integer; begin readln(a, b); if(a = b) then write(1) else write(0); end.
3) var a, b, c, s: integer; begin s := 0; readln(a, b, c); if(a >= 0) then s := s + 1; if(b >= 0) then s := s + 1; if(c >= 0) then s := s + 1; write(s); end.
4) var a, b, c, s: integer; begin s := 0; readln(a, b, c); if(a > 0) then s := s + a; if(b > 0) then s := s + b; if(c > 0) then s := s + c; write(s); end. 5) var a, b, c: integer; begin readln(a, b, c); if (a < b) then swap(a, b); if (a < c) then swap(a, c); if (b < c) then swap(b, c); write(a, ' ', b, ' ', c); end.
6) var n, k, s, i: integer; begin s := 0; readln(n, k); for i := 1 to n.ToString.Length do if(strtoint(n.ToString[i]) > k) then s := s + strtoint(n.ToString[i]); write(s); end.
7) var n, s, i: integer; begin s := 0; readln(n); for i := 1 to n do s := s + i; write(s); end.
9) var n, i: integer; begin readln(n); for i := n downto 1 do write(i); end.
12 var n, i: integer; s: real; begin s := 0; readln(n); for i := n downto 1 do s:=s+(0.1*i); write(s); end.
13) var n, i: integer; begin readln(n); for i := 1 to n do write(sqr(i), ' '); end.
14) var n, i, c: integer; begin i := 1; c := 0; readln(n); while (c <> n) do begin if(i mod 3 = 0) then begin write(i, ' ');c := c + 1; end; i := i + 1; end; end.
15) var n, i, a: integer; c: real; begin i := 1; c := 0; readln(n); for i := 1 to n do begin read(a); c := c + a; end; write(c / n) end.
16) var n, i, a: integer; begin i := 1; while true do begin read(a); if(a = 0) then break; n := n + 1; end; write(n) end.
1) 255₁₀ = 11111111₂
2) 255₁₀ = 377₈
3) 255₁₀ = FF₁₆
4) 397₁₀ = 110001101₂
5) 397₁₀ = 615₈
6) 397₁₀ = 18D₁₆
Объяснение:
1) 255₁₀ = 11111111₂
255 / 2 = 127 + остаток 1
127 / 2 = 63 + остаток 1
63 / 2 = 31 + остаток 1
31 / 2 = 15 + остаток 1
15 / 2 = 7 + остаток 1
7 / 2 = 3 + остаток 1
3 / 2 = 1 + остаток 1
1 / 2 = 0 + остаток 1
записываем остатки снизу вверх
11111111₂ = 1 * 2⁰ + 1 * 2¹ + 1 * 2² + 1 * 2³ + 1 * 2⁴ + 1 * 2⁵ + 1 * 2⁶ + 1 * 2⁷ = 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 = 255₁₀
2) 255₁₀ = 377₈
255 / 8 = 31 + остаток 7
31 / 8 = 3 + остаток 7
3 / 8 = 0 + остаток 3
записываем остатки снизу вверх
377₈ = 7 * 8⁰ + 7 * 8¹ + 3 * 8² = 7 + 56 + 192 = 255₁₀
3) 255₁₀ = FF₁₆
255 / 16 = 15 + остаток 15
15 / 16 = 0 + остаток 15
записываем остатки снизу вверх
FF₁₆ = F * 16⁰ + F * 16¹ = 15 + 240 = 255₁₀
4) 397₁₀ = 110001101₂
397 / 2 = 198 + остаток 1
198 / 2 = 99 + остаток 0
99 / 2 = 49 + остаток 1
49 / 2 = 24 + остаток 1
24 / 2 = 12 + остаток 0
12 / 2 = 6 + остаток 0
6 / 2 = 3 + остаток 0
3 / 2 = 1 + остаток 1
1 / 2 = 0 + остаток 1
записываем остатки снизу вверх
110001101₂ = 1 * 2⁰ + 0 * 2¹ + 1 * 2² + 1 * 2³ + 0 * 2⁴ + 0 * 2⁵ + 0 * 2⁶ + 1 * 2⁷ + 1 * 2⁸ = 1 + 4 + 8 + 128 + 256 = 397₁₀
5) 397₁₀ = 615₈
397 / 8 = 49 + остаток 5
49 / 8 = 6 + остаток 1
6 / 8 = 0 + остаток 6
записываем остатки снизу вверх
615₈ = 5 * 8⁰ + 1 * 8¹ + 6 * 8² = 5 + 8 + 384 = 397₁₀
6) 397₁₀ = 18D₁₆
397 / 16 = 24 + остаток 13
24 / 16 = 1 + остаток 8
1 / 16 = 0 + остаток 1
записываем остатки снизу вверх
18D₁₆ = D * 16⁰ + 8 * 16¹ + 1 * 16² = 13 + 128 + 256 = 397₁₀
var
n:integer;
begin
readln(n);
if(n<0)then write(0)
else write(n+4);
end.
2)
var
a, b: integer;
begin
readln(a, b);
if(a = b) then
write(1)
else
write(0);
end.
3)
var
a, b, c, s: integer;
begin
s := 0;
readln(a, b, c);
if(a >= 0) then s := s + 1;
if(b >= 0) then s := s + 1;
if(c >= 0) then s := s + 1;
write(s);
end.
4)
var
a, b, c, s: integer;
begin
s := 0;
readln(a, b, c);
if(a > 0) then s := s + a;
if(b > 0) then s := s + b;
if(c > 0) then s := s + c;
write(s);
end.
5)
var
a, b, c: integer;
begin
readln(a, b, c);
if (a < b) then swap(a, b);
if (a < c) then swap(a, c);
if (b < c) then swap(b, c);
write(a, ' ', b, ' ', c);
end.
6)
var n, k, s, i: integer;
begin
s := 0;
readln(n, k);
for i := 1 to n.ToString.Length do
if(strtoint(n.ToString[i]) > k) then s := s + strtoint(n.ToString[i]);
write(s);
end.
7)
var n, s, i: integer;
begin
s := 0;
readln(n);
for i := 1 to n do
s := s + i;
write(s);
end.
9)
var n, i: integer;
begin
readln(n);
for i := n downto 1 do
write(i);
end.
12
var
n, i: integer;
s: real;
begin
s := 0;
readln(n);
for i := n downto 1 do
s:=s+(0.1*i);
write(s);
end.
13)
var n, i: integer;
begin
readln(n);
for i := 1 to n do
write(sqr(i), ' ');
end.
14)
var
n, i, c: integer;
begin
i := 1;
c := 0;
readln(n);
while (c <> n) do
begin
if(i mod 3 = 0) then begin write(i, ' ');c := c + 1; end;
i := i + 1;
end;
end.
15)
var
n, i, a: integer;
c: real;
begin
i := 1;
c := 0;
readln(n);
for i := 1 to n do
begin
read(a);
c := c + a;
end;
write(c / n)
end.
16)
var
n, i, a: integer;
begin
i := 1;
while true do
begin
read(a);
if(a = 0) then break;
n := n + 1;
end;
write(n)
end.