Compter les occurences d'un mot dans une chaîne
mon prgramme ne s'execute pas; il consiste a compter les occurences du mot (mot) dans la chaine de caractères(ch) ,le voici:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
function occ_mot(ch: string;var mot: string):integer;
var l,cpt:integer;
m:string;
begin
l:=1;
cpt:=0;
while l<=length(ch) do
begin
while (ch[l] in sep) do
begin
l:=l+1;
end;
if ch[l]= mot[1] then
begin
while not (ch[l] in sep) do
l:=l+1;
if l= length(mot)-1 then
begin
m:=copy(ch,l-length(mot)+1,length(mot));
if m=mot then
cpt:=cpt+1;
end;
end;
end;
occ_mot:=cpt;
end; |
aidez moi svp.