Program S6;
Type
Tab = Array[1..10] Of String;
Var
T1,T2 : tab;
N,N2 : integer;
//***********************************
Procedure Saisie(Var N:integer);
Begin
Repeat
Write('Entrer la taille du tableau : ');
Readln(n);
Until n In [2..10];
End;
//***********************************
Procedure Remplissage(Var T:tab; N:integer);
Var
i : integer;
Begin
For i:=1 To n Do
Repeat
Write('Donner une adresse e-mail : ');
Readln(T[i]);
Until (length(T[i])<=25) And (UpCase(T[i][1]) In ['A'..'Z']) And
(POS('@',T[i]) In [2..length(T[i])-1] );
End;
//***********************************
Function nb_occurence(ch:String; T:tab; N:integer) : integer;
Var
i,nb : integer;
Begin
nb := 0;
For i:=1 To N Do
If (T[i] = ch) Then
nb := nb+1;
nb_occurence := nb;
End;
//***********************************
Procedure Serveurs(N:integer; T1:tab; Var T2:tab; Var N2:integer);
Var
i : integer;
ch : String;
Begin
N2 := 0;
For i:=1 To n Do
Begin
ch := Copy(T1[i] ,pos('@',T1[i])+1, length(T1[i])-pos('@',T1[i]));
If (nb_occurence(ch,T2,N)=0) Then
Begin
N2 := N2+1;
T2[N2] := ch;
End;
End;
End;
//***********************************
Procedure Afficher(N:integer; T:tab);
Var
i : integer;
Begin
Writeln('Les noms des serveurs sont : ');
For i:=1 To n Do
Writeln(T[i]);
End;
//***********************************
Begin
Saisie(N);
Remplissage(T1,N);
Serveurs(N, T1, T2, N2);
Afficher(N2,T2);
End.
Inscription à :
Publier les commentaires (Atom)