1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
Program carnetdadresse;
Type personne=record
nom: string;
prenom: string;
tel: word;
End;
Var choix, nbr: byte;
tab: array [0..19] of personne;
Function menu_add():integer;
Var info: personne;
i: byte;
Begin
i:=0; nbr:=0;
Write ('Nom: ');
ReadLn (info.nom);
Write ('Prenom: ');
ReadLn (info.prenom);
Write ('Telephone: ');
ReadLn (info.tel);
WriteLn;
While (i<nbr) AND (tab[i].nom<=info.nom) do
Begin
i:=i+1;
End;
While (nbr<i) do
Begin
tab[i]:=tab[i+1];
End;
tab[i]:=info;
nbr:=nbr+1;
WriteLn ('La personne ci-dessus a ete ajoute...');
WriteLn;
End;
Function menu_delete():integer;
Var i: byte;
nom: string;
Begin
i:=0;
Write ('Nom: ');
ReadLn (nom);
While (i<nbr) do
Begin
If (tab[i].nom=nom) then
Begin
WriteLn('Prenom: ',tab[i].prenom);
WriteLn('Telephone: ',tab[i].tel);
WriteLn;
WriteLn ('Vous avez supprimer le contact ci-dessus');
WriteLn;
End
Else
Begin
WriteLn ('Aucune personne ne correspond a votre recherche...');
WriteLn;
End;
i:=i+1;
End;
End;
Function menu_search():integer;
Var nom: string;
i: byte;
Begin
i:=0;
Write ('Nom: ');
ReadLn (nom);
While (tab[i].nom<>nom) do
Begin
i:=i+1;
End;
If (tab[i].nom=nom) then
Begin
WriteLn('Prenom: ',tab[i].prenom);
WriteLn('Telephone: ',tab[i].tel);
End
Else
Begin
WriteLn ('Aucune personne ne correspond a votre recherche...');
WriteLn;
End;
WriteLn;
End;
Function menu_read():integer;
Var i: byte;
Begin
i:=0;
If (nbr>0) then
Begin
While (i<nbr) do
Begin
WriteLn('Nom: ',tab[i].nom);
WriteLn('Prenom: ',tab[i].prenom);
WriteLn('Telephone: ',tab[i].tel);
WriteLn;
i:=i+1;
End;
End
Else
Begin
WriteLn ('Il n''y a personne...');
WriteLn;
End;
WriteLn ('Pressez ENTER pour revenir au menu principal');
ReadLn;
clrscr;
End;
Begin
While (choix<>5) do
Begin
choix:=0;
WriteLn ('1) Ajouter une personne');
WriteLn ('2) Supprimer une personne');
WriteLn ('3) Rechercher une personne');
WriteLn ('4) Afficher toutes les personnes');
WriteLn ('5) Quitter');
WriteLn;
Write ('Que voulez vous faire? ');
ReadLn (choix);
If (choix=1) then menu_add
Else
If (choix=2) then menu_delete
Else
If (choix=3) then menu_search
Else
If (choix=4) then menu_read
Else
If (choix<>5) then
Begin
WriteLn ('Veuillez entrer un chiffre valide');
WriteLn;
End;
End;
End. |
Partager