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
| Program Gestion_Table;
Uses Crt;
Const taillemax = 20; anac = 2003; valcarnom ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
Type identite = Record
matricule : Integer;
nom : String[25];
datenais : Record
annee : Integer;
mois : Integer;
jour : Integer;
End;
End;
Type tab = Array[0..taillemax] Of identite;
Function lireentier(vmin, vmax : Integer): Integer;
Var n, err, x, y : Integer; ch : String[7];
Begin
Repeat
x:=Wherex; y:=Wherey;
Readln(ch);
Gotoxy(x,y); Clreol;
Val (ch,n,err);
Until (err=0) And (n<=vmax) And (n>=vmin);
Writeln (n);
lireentier:=n;
End;
Function lirenom(lgch : Integer): String;
Var x, y : Integer; ch : String[25];
Begin
Repeat
x:=Wherex; y:=Wherey;
Readln(ch);
Gotoxy(x,y); Clreol;
Until (Length(ch)>=1) And (Length(ch)<=lgch) And (Pos(ch[1],valcarnom)>0);
Writeln (ch);
lirenom:=ch;
End;
Var personne : identite;
table : tab;
aa : Char;
co, i, x, y : Integer;
Begin
co:=1; aa:=' ';
Clrscr;
Writeln ('Vous allez rentrer les fiches d''identite de personnes (max: ',taillemax,' )');
Gotoxy(5,40);
Writeln ('Frappez une touche pour continuer ...'); aa:=Readkey;
Clrscr;
[b]Writeln ('Personne : ',co);
Writeln ('==============');
Writeln;
Write ('Matricule (1 - 2000) [0 => Fin de l''enregistrement] : ');
personne.matricule:=lireentier(0,2000);
While personne.matricule<>0 Do Begin
Writeln;
Write ('Nom : ');
personne.nom:=lirenom(25);
Writeln;
Writeln ('Date de naissance');
Writeln ('-----------------');
Write ('Jour : ');
With personne.datenais Do Begin
jour:=lireentier(1,31);
Write ('Mois : ');
mois:=lireentier(1,12);
Write ('Annee : ');
annee:=lireentier(1900,anac);
End;
table[co]:=personne;
Inc(co);
If co<=taillemax Then Begin
Clrscr;
Writeln ('Personne : ',co);
Writeln ('==============');
Writeln;
Write ('Matricule (1 - 2000) [0 => Fin de l''enregistrement] : ');
personne.matricule:=lireentier(0,2000)
End
Else personne.matricule:=0
End;[/b]
Dec(co);
table[0].matricule:=-1;
Clrscr;
Writeln (' MENU');
Writeln (' ====');
Writeln;
Writeln ('Pour afficher le contenu de la table ........... 1');
Writeln ('Pour trier la table selon les matricules ....... 2');
Writeln ('Pour trier la table selon les noms ............. 3');
Writeln ('Pour trier la table selon l''age (decroissant) .. 4');
Writeln ('Pour ajouter un element a la table ............. 5');
Writeln ('Pour quitter le programme ...................... 6');
Gotoxy(5,15);
Write ('Faites votre choix : ');
Repeat
x:=wherex; y:=wherey;
aa:=readkey;
Gotoxy(x,y);
Clreol;
Until Pos (aa,'123456')>0;
Case aa Of
'1': Begin
Clrscr;
Writeln ('| Personne | Matricule | Nom | Date de naissance |');
Writeln ('|----------------------------------------------------------------------|');
Writeln ('| | | | |');
For i:=1 to co Do Begin
With table[i] Do Begin
Write ('|',i:9,' | ',matricule:9,' | ',nom:25);
Writeln (' | ',datenais.jour:2,'/',datenais.mois:2,'/',datenais.annee:4,' |');
End;
End;
End;
'2': Begin
End;
'3': Begin
End;
'4': Begin
End;
'5': Begin
End;
End;
Gotoxy(5,40);
Writeln ('Frappez une touche pour finir ...'); aa:=Readkey
End. |
Partager