В заданном тексте подсчитайте общее количество букв «x» и «y» — Pascal(Паскаль)

program xiy;
uses crt;
var text:string;
a,b,number:integer;
letter:char;
begin
clrscr;
writeln('vvedite text:');
readln(text);
number:=0;
for a:=1 to length(text) do
begin
letter:=text[a];
if (letter='x') or (letter='y') then number:=number+1;
end;
writeln('otvet: obshee kol-vo "x" i "y"=',number);
readkey;
end.

Вариант № 2

Var
 T: string;
 i, summ: byte;
Begin
 Writeln('Введи текст: ');
 Readln(T);
 summ:=0;
 For i:=1 to length(T) do
  If T[i] in ['y','x'] then inc(summ);
 Writeln('Сумма = ',summ);
End.

Leave a Comment

30 − 21 =