writeln('Il y a : ', nblettre(result), 'dans la phrase :"', phrase, '".');
if (upcase(phrase[x])=lettre)
if (upcase(phrase[x])=upcase(lettre))
nblettre:=result; nblettre:=nbchar;
var phrase:string; result:integer; lettre:char; nbchar:integer; function nblettre ( phrase : string; lettre :char ) : integer; var x:integer; begin nbchar := 0; result := 0; for x:=1 to length(phrase) do begin if (upcase(phrase[x])>='A') and (upcase(phrase[x])<='Z') then inc(result); if (upcase(phrase[x])=upcase(lettre)) then inc(nbchar); end; end; begin Write('Entrez une phrase : '); Readln(phrase); Write('Entrez une lettre : '); Readln(lettre); writeln('Il y a : ', nblettre(phrase,lettre), ' lettre dans la phrase :"', phrase, '".'); writeln('Dans cette phrase, il y a ',nbchar , ' fois la lettre "',lettre,'".'); readln; end.
{$APPTYPE CONSOLE}
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionprogram fonction_nb_lettre_phrase; var phrase:string; result:integer; lettre:char; nbchar:integer; nLettres:integer; Procedure nblettre ( phrase : string; lettre :char ); var x:integer; begin nblettres:=0; nbchar:=0; for x:=1 to length(phrase) do begin if (upcase(phrase[x])>='A') and (upcase(phrase[x])<='Z') then inc(nblettres); if (upcase(phrase[x])=lettre) then inc(nbchar); end; end; begin Write('Entrez une phrase : '); Readln(phrase); Write('Entrez une lettre : '); Readln(lettre); nblettre(phrase,lettre); writeln('Il y a : ', inttostr(nblettres), 'dans la phrase :"', phrase, '".'); writeln('Dans cette phrase, il y a ', inttostr(nbchar), ' lettre "', lettre,'".'); readln; end.
var phrase:string; result:integer; lettre:char; nbchar:integer;