Determinati numarul cuvintelor in propozitie.
Program Sir6;
uses Crt;
var s: string;
i,k:byte;
begin
ClrScr;
write('Scrie textul: &
{lichidam spatiile de debut}
while s[1]=' ' do Delete(s,1,1);
{lasam intre cuvinte doar un spatiu}
i:=1;
repeat
if Copy(s,i,2)=' ' then Delete(s,i,1) else Inc( i ) ;
until i>Length( s ) ;
k:=1;
for i:=1 to Length ( s ) do
if s[i]=' ' then Inc( k ) ;
write('Numarul de cuvinte: ',k);
ReadKey;
end.
Присоединяйтесь — мы покажем вам много интересного
Присоединяйтесь к ОК, чтобы подписаться на группу и комментировать публикации.
Комментарии 3
Program Sir6;
uses Crt;
var s: string;
i,k:byte;
begin
ClrScr;
write('Scrie textul: &
#39{lichidam spatiile de debut}
while s[1]=' ' do Delete(s,1,1);
{lasam intre cuvinte doar un spatiu}
i:=1;
repeat
if Copy(s,i,2)=' ' then Delete(s,i,1) else Inc( i ) ;
until i>Length( s ) ;
k:=1;
for i:=1 to Length ( s ) do
if s[i]=' ' then Inc( k ) ;
write('Numarul de cuvinte: ',k);
ReadKey;
end.