HOME ПРИМЕРЫ THANKS НОВИЧКАМ ДОКИ LINKS JavaScript Mail |
|
|
var st,w:string; k,i:byte; what2look:char; begin st:='This is just an example string wich has few commas.'; what2look:=' '; i:=pos(what2look,st); write('Words: '); while (i>0) do begin w:=copy(st,1,i-1); delete(st,1,i); if (length(w)=3) then write(w,', '); i:=pos(what2look,st); end; writeln; end. |
Комментарии to top Решение Автор: Moderator |
var s,w:string; k,i,wc:byte; begin s:='This This is a test line This line has few words Each one of the words of this line is not unic'; writeln; writeln('Sentence: '+s); s:=s+' '; {Assume there is no commas, no dots there. Otherwise first remove them } k:=Pos(' ',s); while (k>0) do begin w:=copy(s,1,k-1); s:=copy(s,k+1,255); i:=Pos(' '+w+' ',' '+s); wc:=1; while (i>0) do begin inc(wc); s:=copy(s,1,i-1)+copy(s,i+length(w)+1,255); i:=Pos(' '+w+' ',' '+s); end; writeln('word: ''',w:15,''' has been met ',wc,' times'); k:=Pos(' ',s); end; end. |
HOME EXAMPLES |
|