Program S18;
Type
tab = array [1..20] Of string[10];
Var
t : tab;
n,p : integer;
//**********************************
Procedure saisie(Var n,p: integer);
Begin
Repeat
write('N = ');
readln(n);
Until n In [3..20];
Repeat
write('P = ');
readln(p);
Until p In [1..10];
End;
//**********************************
Procedure remplir(Var t:tab;n,p:integer);
Var
i,j : integer;
Begin
For i:=1 To n Do
Begin
T[i] := '';
For j:=1 To p Do
T[i] := T[i]+chr(random(26)+65);
End;
For i:=1 To n Do
writeln(t[i],' ');
End;
//**********************************
Procedure affich(t:tab;n,p:integer);
Type
tab2 = array['A'..'Z'] Of integer;
Var
i,k : integer;
j : char;
T2 : tab2;
Function max(t2:tab2) : integer;
Var
maxi : integer;
i : char;
Begin
maxi := T2['A'];
For i:='B' To 'Z' Do
If maxi < T2[i] Then
maxi := T2[i];
max := maxi;
End;
//**********************************
Begin
For j:='A' To 'Z' Do
T2[j] := 0;
For i:=1 To n Do
For k:=1 To p Do
T2[T[i,k]] := T2[T[i,k]]+1;
write('Les lettres porte-bonheur sont : ');
For j:='A' To 'Z' Do
If T2[j]=max(T2) Then
write(j,' ');
End;
//**********************************
Begin
randomize;
saisie(n,p);
remplir(t,n,p);
affich(t,n,p);
End.
Inscription à :
Publier les commentaires (Atom)