Var currentPos,wordsAmount:byte; groupWords:string; procedure isCorrect(startPos:byte); begin while currentPos+1<=length(groupWords) do if groupWords[currentPos+1]<>' ' then inc(currentPos) else break; if groupWords[startPos]=groupWords[currentPos] then inc(wordsAmount); end; begin readln(groupWords); wordsAmount:=0; currentPos:=1; while currentPos<=length(groupWords) do begin if (groupWords[currentPos]<>' ') then isCorrect(currentPos); inc(currentPos); end; writeln(wordsAmount); readln; end.
n = 3; //Кол-во фигур
var
i : integer;
xk,yk : integer;
xl,yl : array [1..n] of integer;
r : boolean;
begin
//Задание координат
//
xk := 2; yk := 2; // Координаты короля
//Координаты ладьи
xl[1] := 1; yl[1] := 2;
xl[2] := 4; yl[2] := 6;
xl[3] := 5; yl[3] := 8;
//
r := false;
i := 1;
While (i <= n) and (not r) do
begin
if (xk = xl[i]) or (yk = yl[i]) then //Лежат на одной прямой
r := true;
i:= i +1;
end;
if r then
writeln ('Король под ударом')
else
writeln ('Король живет)');
end.
currentPos,wordsAmount:byte; groupWords:string;
procedure isCorrect(startPos:byte);
begin
while currentPos+1<=length(groupWords) do
if groupWords[currentPos+1]<>' ' then inc(currentPos) else break;
if groupWords[startPos]=groupWords[currentPos] then
inc(wordsAmount);
end;
begin
readln(groupWords); wordsAmount:=0; currentPos:=1;
while currentPos<=length(groupWords) do
begin
if (groupWords[currentPos]<>' ') then isCorrect(currentPos);
inc(currentPos);
end;
writeln(wordsAmount); readln;
end.