Program S24;
Var
nombre : integer;
//*******************************
Procedure lecture(Var nombre:integer);
Begin
Repeat
write('Nombre (impair) :');
readln(nombre);
Until (nombre Mod 2 <> 0) And (nombre In [1..9]);
End;
//*******************************
Function div_7(chaine:String) : boolean;
Var
somme,s,signe,i,j : integer;
ch : string;
Begin
j := 0;
somme := 0;
signe := 1;
ch := '';
For i:=length(chaine) Downto 1 Do
Begin
j := j+1;
ch := chaine[i]+ch;
If (j=3) Or (i=1) Then
Begin
j := 0;
val(ch,s);
ch := '';
somme := somme+(s*signe);
signe := signe*(-1);
End;
End;
div_7 := somme Mod 7 = 0 ;
End;
//*******************************
Procedure affich(nombre:integer);
Var
nb_ligne,i,somme,nb,c : integer;
chaine,c2 : string;
Begin
str(nombre,chaine);
nb_ligne := 0;
writeln(chaine:31);
Repeat
somme := 0;
nb_ligne := nb_ligne+1;
For i:=1 To length(chaine) Do
Begin
val(chaine[i],nb);
somme := somme+nb;
End;
c := (somme+length(chaine)) Mod 10;
str(c,c2);
chaine := c2+chaine+c2;
writeln(chaine:31+nb_ligne);
Until div_7(chaine);
End;
//*******************************
Begin
lecture(nombre);
affich(nombre);
End.
Inscription à :
Publier les commentaires (Atom)