var
s : string;
i : integer;
f : boolean;
begin
readln (s);
writeln ('Тут ', length (s), ' символов');
f := true;
for i := 1 to length (s) div 2 do
if s[i] <> s[length (s) - i + 1] then f := false;
writeln ('Это слово является перевертышем: ', f); //True/False
end.
i, k, count : integer;
c : char;
count := 0;
for i := 1 to length (s) do
if s[i] <> ' ' then
c := s[i];
k := i + 1;
break;
end;
for i := k to length (s) do
if (s[i] = ' ') and (c <> ' ') then
if s[i - 1] = c then inc (count);
c := ' ';
end
else if c = ' ' then c := s[i];
if (c <> ' ' ) and (s[length (s)] <> ' ') and (c = s[length (s)]) then inc (count);
writeln (count);
Объяснение:
const
max_elements = 1000;
a = 1;
b = 15;
first_file_name = '1.txt';
second_file_name = '2.txt';
i, j, n, r:integer;
p:real;
ar:array[1..max_elements] of integer;
f1, f2:text;
randomize;
writeln('Input n = ');
readln(n);
for i:=1 to n do begin
ar[i]:=random(b-a+1)+a;
assign(f1, first_file_name);
rewrite(f1);
writeln(f1, ar[i]);
close(f1);
assign(f2, second_file_name);
rewrite(f2);
p:=1;
for j:=1 to i do
p:=p*ar[j];
writeln(f2, p:0:0);
close(f2);
readln;
var
s : string;
i : integer;
f : boolean;
begin
readln (s);
writeln ('Тут ', length (s), ' символов');
f := true;
for i := 1 to length (s) div 2 do
if s[i] <> s[length (s) - i + 1] then f := false;
writeln ('Это слово является перевертышем: ', f); //True/False
end.
var
s : string;
i, k, count : integer;
c : char;
begin
readln (s);
count := 0;
for i := 1 to length (s) do
if s[i] <> ' ' then
begin
c := s[i];
k := i + 1;
break;
end;
for i := k to length (s) do
if (s[i] = ' ') and (c <> ' ') then
begin
if s[i - 1] = c then inc (count);
c := ' ';
end
else if c = ' ' then c := s[i];
if (c <> ' ' ) and (s[length (s)] <> ' ') and (c = s[length (s)]) then inc (count);
writeln (count);
end.
Объяснение:
const
max_elements = 1000;
a = 1;
b = 15;
first_file_name = '1.txt';
second_file_name = '2.txt';
var
i, j, n, r:integer;
p:real;
ar:array[1..max_elements] of integer;
f1, f2:text;
begin
randomize;
writeln('Input n = ');
readln(n);
for i:=1 to n do begin
ar[i]:=random(b-a+1)+a;
end;
assign(f1, first_file_name);
rewrite(f1);
for i:=1 to n do begin
writeln(f1, ar[i]);
end;
close(f1);
assign(f2, second_file_name);
rewrite(f2);
for i:=1 to n do begin
p:=1;
for j:=1 to i do
p:=p*ar[j];
writeln(f2, p:0:0);
end;
close(f2);
readln;
end.