строки
Добавлено: 10 дек 2009, 19:13
проверьти пожалуйста, правельно ли у меня тут все сделано или нет!!
Зарание спасибо!!!!!
Код: Выделить всё
program prog;
uses crt;
var
z:byte;
s,temp:string;
i,j,c,ca:integer;
const
dividers=[' ',',','.',';',':','-','=','+'];
procedure menu (var z:byte);
begin
writeln;
writeln('1-ввод ');
writeln('2-Подсчитать количество слов в данной последовательности.');
writeln('3-Подсчитать количество букв "а" в последнем слове данной последовательности');
writeln('4-Найти количество слов, начинающихся с буквы "б"');
writeln('5-Найти количество слов, у которых первый и последний символы совпадают между собой');
writeln('6-Найти какое-нибудь слово, начинающееся с буквы "а"');
writeln('7-Преобразовать данную последовательность, заменяя всякое вхождение слова "это" на слово "то"’);
writeln('8-Найти длину самого короткого слова');
writeln('0-Выход');
readln(z);
writeln;
end;
procedure vvod(var s:string);
begin
textcolor(12);
writeln('введите строчку:');
readln(s);
textcolor(0);
writeln;
end;
procedure kol_clov (var s,temp:string; i,j,c,ca:integer);
begin
textcolor(12);
write(s);
textcolor(0);
temp:='';
c:=0;
for i:=1 to length(s) do
begin
if not (s[i] in dividers) then
temp:=temp+s[i];
if (s[i] in dividers) or (i=length(s)) then
begin
if temp<>'' then
begin
temp:='';
inc(c)
end;
end;
end;
writeln;
textcolor(green);
writeln('всего слов: ',c) ;
textcolor(0);
end;
procedure zamena(var s:string;i:integer);
begin
textcolor(12);
write(s);
textcolor(0) ;
while pos('это', s) > 0 do
begin
i := pos('это', s);
s := copy(s, 1, i-1) + 'то' + copy(s, i+3, maxint);
end;
writeln;
textcolor(green);
write(s);
textcolor(0) ;
end;
procedure bukva_a (var s,temp:string; i,j,c,ca:integer) ;
begin
textcolor(12);
write(s);
textcolor(0);
writeln;
temp:='';
c:=0;
for i:=1 to length(s) do
begin
if not (s[i] in dividers) then
temp:=temp+s[i];
if (s[i] in dividers) or (i=length(s)) then
begin
if temp<>'' then
begin
ca:=0;
for j:=1 to length(temp) do
if temp[j] in ['а','А','a','A'] then
inc(ca);
temp:='';
inc(c)
end;
end;
end;
textcolor(green);
writeln('количество букв "а" в последнем слове: ',ca) ;
textcolor(0);
end;
procedure clova_c_1_b (var s,temp:string; i,j,c,ca:integer) ;
begin
textcolor(12);
write(s);
textcolor(0);
ca:=0;
for i:=1 to length(s) do
begin
if not (s[i] in dividers) then
temp:=temp+s[i];
if (s[i] in dividers) or (i=length(s)) then
begin
if temp<>'' then
begin
if temp[1] in ['Б','б'] then
inc(ca);
temp:=''
end;
end;
end;
writeln;
textcolor(green);
writeln('количество слов, начинающихся с буквы "б": ',ca);
textcolor(0);
end;
procedure perv_u_posl_cumvl_covpod (var s,temp:string; i,j,c,ca:integer) ;
begin
textcolor(12);
write(s);
textcolor(0);
c:=0;
for i:=1 to length(s) do
begin
if not (s[i] in dividers) then
temp:=temp+s[i];
if (s[i] in dividers) or (i=length(s)) then
begin
if temp<>'' then
begin
if temp[1]=temp[length(temp)] then
inc(c);
temp:=''
end;
end;
end;
writeln;
textcolor(green);
writeln('количество слов, у которых первый и последний символы совпадают между собой: ',c) ;
textcolor(0);
end;
BEGIN
z:=1;
While z<>0 do begin
menu(z);
case z of
1: vvod(s);
2: kol_clov (s,temp,i,j,ca,c);
3: bukva_a (s,temp,i,j,ca,c) ;
4: clova_c_1_b (s,temp,i,j,ca,c) ;
5: perv_u_posl_cumvl_covpod (s,temp,i,j,ca,c) ;
7: zamena (s,i) ;
end;
end;
end.
Зарание спасибо!!!!!