Program S6;
Var
code : string;
//********************************************
Function verif(ch:String) : boolean;
Var
i : integer;
test,test1 : boolean;
Begin
If (ch[1] In ['A'..'Z']) Then
test1 := true
Else test1 := false;
i := 1;
Repeat
i := i+1;
If (i>1) And (ch[i] In ['0'..'9']) Then
test := True
Else test := false;
Until (i>=length(ch)) Or Not(test);
verif := test And test1 And (length(ch)=12);
End;
//********************************************
Function authentique(ch:String) : boolean;
Var
d,e,i,s : integer;
aux : string;
Begin
str(ord(ch[1])-64,aux);
delete(ch,1,1);
ch := aux+ch;
s := 0;
For i:=1 To length(ch) Do
Begin
val(ch[i],d,e);
s := s+d;
End;
authentique := (s Mod 9 = 8);
End;
//********************************************
Begin
Repeat
write('saisir le code à valider :');
readln(code);
Until verif(code);
If authentique(code) Then
writeln('c''est un billet authentique')
Else writeln('attention! ce billet n''est pas authentique');
End.
Inscription à :
Publier les commentaires (Atom)