Accueil     Soft. MacOSX     Soft. MacOS/PC     PHP     Python     ROMS GBA     TP d'info     DBZ-GT     Martingales     Galeries     Liens     @  

Exercice 3


program ex3;

function compte_char (nom_fichier: string; c: char): integer;
 var
   f: file of char;
   i: integer;
   h: char;

begin
 reset(f, nom_fichier);
{ PC: assign(f,nom_fichier); reset(f); }
 i := 0;
 while not eof(f) do
 begin
  read(f, h);
  if h = c then
  i := i + 1;
 end;

 close(f);
 compte_char := i;
end;
{ Fin de 'compte_char' }

function compte_bichar (nom_fichier: string; c, d: char): integer;
 var
   f: file of char;
   i: integer;
   h: char;
   t: boolean;

begin
 reset(f, nom_fichier);
{ PC: assign(f,nom_fichier); reset(f); }
 i := 0;
 t := false;

 while not eof(f) do
 begin
 read(f, h);
 if t then
 begin
 if h = d then
 i := i + 1;
 t := false;
 end
 else
 begin
 if h = c then
 t := true
 else { inutile }
 t := false; { inutile }
 end;
 end;

 close(f);
 compte_bichar := i;
end;
{ Fin de 'compte_char' }

begin

 writeln(compte_char('didier', 'd'));
 writeln(compte_bichar('didier', 'd', 's'));

{ ©2000 All Rights reserved to http://www.Software-DS.com }
end.

Retour

Page d'Accueil
Apple





Haut de la page - Page précédente - Page générée en 0.02856 sec.
Recherche personnalisée
 

1843925 visiteurs.   ©2001-2023 All Rights Reserved to Software-DS.com
Made with a mac  
Confidentialité