Program S19;
Var
ch : string;
//*********************************
Function Valide (ch : String) : Boolean;
Var
i : integer;
b : boolean;
Begin
i := 0;
Repeat
i := i + 1;
b := upcase(ch[i]) In ['A'..'Z',' '];
Until Not(b) Or (i=Length(ch));
Valide := b;
End;
//*********************************
Function Tautogramme (ch:String) : boolean;
Var
p : integer;
b : boolean;
Begin
Repeat
p := pos(' ',ch);
If p=0 Then
b := false
Else
Begin
b := ch[1]=ch[p+1];
delete(ch,1,p);
End;
Until (b=false) Or (pos(' ',ch)=0);
Tautogramme := b;
End;
//*********************************
Function totalogramme (ch:String) : boolean;
Var
p : integer;
b : boolean;
Begin
ch := ch+' ';
Repeat
p := pos(' ',ch);
b := ch[1]=ch[p-1];
delete(ch,1,p);
Until (b=false) Or (ch='');
totalogramme := b;
End;
//*********************************
Procedure Saisie (Var CH:String);
Begin
Repeat
Write('Saisir une chaine : ');
Readln(CH);
Until valide(CH);
End;
//*********************************
Procedure Affiche(ch:String);
Begin
If Totalogramme(ch) And Tautogramme(ch) Then
writeln('Totalogramme & Tautogramme ')
Else If Totalogramme(ch) Then
writeln('Totalogramme ')
Else If Tautogramme(ch) Then
writeln('Tautogramme ')
Else
writeln('Non Totalogramme & NonTautogramme ');
End;
//*********************************
Begin
Saisie(ch);
Affiche(ch);
End.
Inscription à :
Publier les commentaires (Atom)