Une solution pour l'exercice 2 du TP3 d'informatique en MIAS+MASS S1
Question 1
program login ;
VAR nom : string[3] ;
prenom : string[2] ;
mdp : string[6] ;
BEGIN
repeat
write('Votre nom (au moins trois lettres) ? ') ;
readln(nom) ;
until length(nom)>=3 ;
repeat
write('Votre prénom (au moins deux lettres) ? ') ;
readln(prenom) ;
until length(prenom)>=2 ;
write('mot de passe ? ') ;
readln(mdp) ;
if mdp=nom+prenom then writeln('login réussi!') ;
END.
Question 2
program login ;
VAR nom : string[3] ;
prenom : string[2] ;
mdp : string[6] ;
BEGIN
repeat
repeat
write('Votre nom (au moins trois lettres) ? ') ;
readln(nom) ;
until length(nom)>=3 ;
repeat
write('Votre prénom (au moins deux lettres) ? ') ;
readln(prenom) ;
until length(prenom)>=2 ;
write('mot de passe ? ') ;
readln(mdp) ;
if mdp=nom+prenom then writeln('login réussi!')
else if mdp<>'' then writeln('nouvel essai...');
until (mdp=nom+prenom) or (mdp='')
END.