Arreglos
Publicado por Naye (2 intervenciones) el 27/04/2012 05:07:21
me podrian ayudar a pasar este programa a arreglos y a unidades? por favor
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
program Agenda1;
type
tipoPersona = record
nombre: string;
email: string;
edad: string;
direccion:string;
end;
const
capacidad = 1000;
var
gente: array[1..capacidad] of tipoPersona;
cantidad: integer;
opcion: integer;
i: integer;
textoBuscar: string;
encontrado: boolean;
{Cuerpo del programa principal}
begin
cantidad := 0;
repeat
WriteLn('AGENDA');
WriteLn;
WriteLn('1- Anadir una nueva persona');
writeln;
WriteLn('2- Ver los datos de de todos');
writeln;
WriteLn('3- Buscar una persona');
writeln;
WriteLn('0- Salir');
writeln;
Write('*****Escoja una opcion:***** ');
ReadLn(opcion);
WriteLn;
case opcion of
1: { Añadir datos de una persona }
if (cantidad < capacidad) then
begin
inc(cantidad);
WriteLn('Introduciendo la persona ', cantidad);
Write('Introduzca el nombre: ');
ReadLn(gente[cantidad].nombre);
Write('Introduzca el correo electronico: ');
ReadLn(gente[cantidad].email);
Write('Introduzca su edad: ');
ReadLn(gente[cantidad].edad);
Write('Introduzca su direccion:');
readln(gente[cantidad].direccion);
WriteLn;
end
else
WriteLn('Base de datos llena');
2: { Ver nombres de todos }
begin
if cantidad = 0 then
WriteLn('No hay datos')
else
for i := 1 to cantidad do
WriteLn(i, ' ', gente[i].nombre);
writeln(i,' ',gente[i].email);
writeln(i,' ',gente[i].edad);
writeln(i,'',gente[i].direccion);
WriteLn;
end;
3: { Buscar una persona }
begin
Write('¿Qué texto busca? ');
ReadLn( textoBuscar );
encontrado := false;
for i := 1 to cantidad do
if pos (textoBuscar, gente[i].nombre) > 0 then
begin
encontrado := true;
WriteLn( i,' - Nombre: ', gente[i].nombre,
', Email: ', gente[i].email,
', Edad: ', gente[i].edad,
',Direccion:',gente[i].direccion);
end;
if not encontrado then
WriteLn('No se ha encontrado.');
WriteLn;
end;
0: { Salir de la aplicación }
begin
WriteLn;
WriteLn('Saliendo...');
WriteLn;
end;
else
begin
WriteLn;
WriteLn('Opción incorrecta!');
WriteLn;
end;
end; { Fin de "case" }
until opcion = 0;
end.
Valora esta pregunta


0