Если лень перебирать вручную, можно воспользоваться программой
var k,l,r,x,f:integer; begin f := 3001; l := 0; r := 65534; x := (l + r) div 2; k := 1; while (x <> f) and (l < r) do begin writeln(k,' ',l,' ',r,' ',x); k := k + 1; if f < x then r := x - 1 else l := x + 1; x := (l + r) div 2 end; writeln(k,' ',l,' ',r,' ',x); end.
var
s: string;
i, count: integer;
begin
writeln('Vvedite stroky: ');
readln(s);
for i := 1 to length(s) - 2 do
if copy(s, i, 3) = 'abc' then
count := count + 1;
writeln('Kol-vo: ', count);
end.
2.
var
s1, s2: string;
i, len1, len2: integer;
begin
writeln('Vvedite stroky 1: ');
readln(s1);
writeln('Vvedite stroky 2: ');
readln(s2);
len1 := length(s1);
len2 := length(s2);
if len1 > len2 then writeln('1 stroka dlinnee')
else if len1 < len2 then writeln('2 stroka dlinnee')
else writeln('dlini strok ravnie')
end.
3.
var
s1, s2, s3: string;
begin
writeln('Vvedite stroky 1: ');
readln(s1);
writeln('Vvedite stroky 2: ');
readln(s2);
s3 := s1[1] + s1[2] + s2[1] + s2[2];
writeln('Novaja stroka: ', s3);
end.
1. 0..65534 -> 32767
2. 0..32766 -> 16383
3. 0..16382 -> 8191
4. 0..8190 -> 4095
5. 0..4094 -> 2047
6. 2048..4094 -> 3071
7. 2048..3070 -> 2559
8. 2560..3070 -> 2815
9. 2816..3070 -> 2943
10. 2944..3070 -> 3007
11. 2944..3006 -> 2975
12. 2976..3006 -> 2991
13. 2992..3006 -> 2999
14. 3000..3006 -> 3003
15. 3000..3002 -> 3001
Если лень перебирать вручную, можно воспользоваться программой
var k,l,r,x,f:integer;
begin
f := 3001;
l := 0;
r := 65534;
x := (l + r) div 2;
k := 1;
while (x <> f) and (l < r) do
begin
writeln(k,' ',l,' ',r,' ',x);
k := k + 1;
if f < x then r := x - 1
else l := x + 1;
x := (l + r) div 2
end;
writeln(k,' ',l,' ',r,' ',x);
end.