Program Nomination;
Type
Tab = Array [1..20] Of String;
Var
N : integer;
Nom : Tab;
//***************************************
Procedure Saisie (Var N : integer);
Begin
Repeat
write('Donner le nombre de produits : ');
readln(N);
Until N In [2..6];
End;
//***************************************
Function Valide (ch : String) : Boolean;
Var
i : integer;
b : boolean;
Begin
i := 0;
Repeat
i := i + 1;
b := ch[i] In ['A'..'Z'];
Until Not(b) Or (i=Length(ch));
Valide := b And (length(ch)=5);
End;
//***************************************
Procedure Remplir (Var Nom : Tab; N : integer);
Var
i : integer;
Begin
For i:=1 To N Do
Begin
Repeat
write('Donner le nom du produit N° ',i,':');
readln(Nom[i]);
Until Valide (Nom[i]);
End;
End;
//***************************************
Function Rotation_symetrique(ch:String) : String;
Var
x : String;
i,L : integer;
Begin
x := '';
L := Length(ch);
For i:= 1 To length(ch) Div 2 Do
x := x+ch[L-i+1]+ch[i];
If Length(Ch) Mod 2 =1 Then
x := x+ch[L Div 2 +1];
Rotation_symetrique := x;
End;
//***************************************
Procedure Spirale (Nom :Tab;N:integer);
Var
i,p : integer;
TP : Tab;
//***************************************
Procedure Affichage (TP : Tab; N : integer);
Var
i : integer;
Begin
writeln('Les N propositions à utiliser sont :');
For i:=1 To N Do
Write(TP[i],' ');
End;
//***************************************
Begin
Repeat
Write('Donner P : ');
Readln(P);
Until P In [1..5];
TP[1] := '';
For i:=1 To N Do
TP[1] := TP[1] + Nom[i][P];
For i:=2 To N Do
TP[i] := Rotation_symetrique(TP[i-1]);
Writeln('La chaîne CH est ',TP[1]);
Affichage(TP,N);
End;
//***************************************
Begin
Saisie (N);
Remplir (Nom,N);
Spirale (Nom,N);
End.
Inscription à :
Publier les commentaires (Atom)