

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


function langeur(str:string): integer; var i: integer; begin i := 0; while str[i+1] <> #0 do i:=i+1; langeur:=i; end;
function concatenation( str1,str2: string): string; begin concatenation:=str1+str2; end;
function sousChaineExiste(chaine,sousChaine:string):boolean; var i,j:integer; existe,found:boolean; begin found := false; i:=1; while (i<=Length(chaine)-Length(sousChaine)+1) and (found=false) do begin if chaine[i]=sousChaine[1] then begin j:=2; existe:=true; while(j<=Length(sousChaine)) and (existe=true) do if chaine[i+j-1] <> sousChaine[j] then existe := false else j:=j+1; end; found:=existe; i:=i+1; end; SousChaineExiste := found; end;
function NombreOccurrences(sousChaine, chaine: string):integer; var i, j, compteur: integer; begin compteur := 0; for i := 1 to length(chaine) - length(sousChaine) + 1 do begin j := 1; while (j <= length(sousChaine)) and (chaine[i + j - 1] = sousChaine[j]) do j:=j+1; if j > length(sousChaine) then compteur:=compteur+1; end; NombreOccurrences := compteur; end;
function remplace (chaine,schaine,nschaine:string):string; var Resultat: string; i,j,n: integer; found: boolean; begin Resultat := ''; i := 1; while i <= Length(chaine) do begin if chaine[i] = schaine[1] then begin found := true; j := 2; while (j <=Length(schaine)) and (j+i- 1 <=Length(chaine)) and (found=true) do if chaine[j+i-1] <> schaine[j]then found := false else j := j + 1; if found and (j+i-1 <= Length(chaine)) then begin Resultat := Resultat + nschaine; i := i + Length(schaine); end else begin Resultat := Resultat + chaine[i]; i := i + 1; end; end else begin Resultat := Resultat + chaine[i]; i := i + 1; end; end; remplace:= Resultat; end;