Ordenamiento de registros
Publicado por Roberto (19 intervenciones) el 05/01/2016 19:35:29
Saludos a la comunidad de este foro, quisiera su ayuda en el metodo de ordenacion de registros, necesito ordenar por el numero de pasaporte. Ejemplo :
22098567 juan espinoza
23654000 elias mendoza
He intentado y no he podidio, por favor ayudenme. Este es mi programa.
22098567 juan espinoza
23654000 elias mendoza
He intentado y no he podidio, por favor ayudenme. Este es mi programa.
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
{Programa incompleto , elaborado por El varon}
program El_Turista_Toursven;
uses
crt;
type
Elturista = record {Registro de los datos de un turista}
Numpas : longint; {Indica el numero de pasaporte}
NombApelli : string[60]; {Indica el Nombre y apellido}
Origenpas:char; {Indica el origen del pasaporte}
end;
const
perso = 30; {Aquí se indica la cantidad máxima de personas}
var
datosturis : array[1..perso] of Elturista;
t, cont : integer;
tec : char;
coven : longint;
procedure incluir;
var
tese:char;
begin
clrscr;
writeln('**** Entrada De Datos Del Turista ****');
writeln;
write(' Nombre Apellido : ');
readln(datosturis[cont].NombApelli);
write(' Numero de pasaporte : ');
readln(datosturis[cont].Numpas);
write(' Origen del pasaporte V / E : ');
repeat
tese := upcase(readkey);
until tese in['E','V'];
write(tese);
datosturis[cont].Origenpas := tese;
readkey;
end;
procedure consultar(codi : longint);
var
encontrado : boolean;
begin
encontrado := false;
for t := 1 to cont do
begin
if datosturis[t].Numpas = codi then
begin
encontrado := true;
break;
end;
end;
if encontrado = true then
begin
clrscr;
writeln('<<< Los Datos Consultados Son >>>');
writeln;
writeln(' Nombre Apellido = ',datosturis[t].NombApelli);
writeln(' Numero de pasaporte = ',datosturis[t].Numpas);
writeln(' Origen del pasaporte = ',datosturis[t].Origenpas);
writeln('<<<<<< Pulse [Enter] >>>>>>>');
readln;
end
else
begin
clrscr;
writeln(' Error El Codigo Insertado No Esta Pulse [Enter]');
readln;
end;
end;
procedure modificar(codi : longint);
var
pul : char;
modi : boolean;
begin
modi := false;
for t := 1 to cont do
begin
if datosturis[t].Numpas = codi then
begin
modi := true;
break;
end;
end;
if modi = true then
begin
repeat
clrscr;
writeln('**** Modificacion De Datos ****');
writeln;
writeln(' 1 = Nombre y Apellido ' ,datosturis[t].NombApelli);
writeln(' 2 = Numero de pasaporte ' ,datosturis[t].Numpas);
writeln(' 3 = Origen del pasaporte ' ,datosturis[t].Origenpas);
writeln(' 4 = finaliza');
repeat
pul := readkey;
until pul in[#49..#52];
case pul of
#49 : begin
write(' Nombre y Apellido : ');
readln(datosturis[t].NombApelli);
end;
#50 : begin
write(' Numero de Pasaporte : ');
readln(datosturis[t].Numpas);
end;
#51 : begin
write(' Origen del pasaporte : ');
readln(datosturis[t].Origenpas);
end;
end;
until pul = #52;
end
else
begin
clrscr;
writeln(' Error El Codigo Insertado No Esta Pulse [Enter]');
readln;
end;
end;
procedure eliminar(codi : longint);
var
pul : char;
borra : boolean;
corre : integer;
begin
borra := false;
for t := 1 to cont do
if datosturis[t].Numpas = codi then
begin
borra := true;
break;
end;
if borra = true then
begin
clrscr;
writeln('<<<<<<<< Anular Registro Vendedor >>>>>>>>>>');
writeln;
writeln(' Numero de pasaporte = ',datosturis[t].Numpas);
writeln;
writeln('Desea Anular Este Turista [S/N]');
repeat
pul := upcase(readkey);
until pul in['S','N'];
if pul = 'S' then
begin
fillchar(datosturis[t],sizeof(datosturis[t]),0);
corre := 1;
for corre := t to cont do
if datosturis[corre].Numpas > 0 then
begin
datosturis[corre] := datosturis[corre - 1];
end;
cont := cont - 1;
end;
end
else
begin
clrscr;
writeln(' Error El Codigo Insertado No Esta Pulse [Enter]');
readln;
end;
end;
procedure ordenararray;
{// ordenamiento burbuja por campo numero de pasaporte}
var
ordenado : boolean;
aux : Elturista;
i : integer;
begin
ordenado := false;
while (not ordenado) do
begin
ordenado := true;
for i := 1 to cont do
begin
if (datosturis[i].numpas > datosturis[i].numpas) then
begin
aux := datosturis[i + 1];
datosturis[i + 1] := datosturis[i];
datosturis[i] := aux;
ordenado := false;
end;
end;
end;
end;
procedure mostrarorden;
var
i:integer;
begin
writeLn('Los datos tras ordenar son: ');
for i := 1 to cont do
write(datosturis[i].Numpas, ' ',datosturis[i].NombApelli);
writeLn;
end;
procedure contadores;
var
t:integer;
vene,extra:integer;
begin
vene := 0;
extra := 0;
Writeln('Datos');
writeln;
for t := 1 to cont do
begin
if (datosturis[t].Origenpas='V') then
begin
vene := vene + 1;
end
else
begin
extra := extra + 1;
end;
end;
begin
WriteLn('Cantidad de venezolanos ',vene);
WriteLn('Cantidad de extranjeros ',extra);
ReadLn;
end;
end;
procedure menu;
var
tee : char;
sas : boolean;
begin
sas := false;
repeat
clrscr;
writeln('******* Menu General *********');
writeln;
writeln(' 1 = INCLUIR');
writeln(' 2 = CONSULTAR');
writeln(' 3 = MODIFICAR');
writeln(' 4 = ELIMINAR');
writeln(' 5 = ORDENAR');
writeln(' 6 = CONTADOR');
writeln(' 7 = SALIR');
writeln;
writeln('<<<<< Elija Opcion >>>>>');
repeat
tee := readkey;
until tee in[#49..#55];
case tee of
#49 : begin
clrscr;
cont := cont + 1;
if cont > perso then
cont := perso;
incluir;
end;
#50 : begin
clrscr;
write(' Entre Numero de pasaporte : ');
readln(coven);
consultar(coven);
end;
#51 : begin
clrscr;
write(' Entre Numero de pasaporte : ');
readln(coven);
modificar(coven);
end;
#52 : begin
clrscr;
write(' Entre Numero de pasaporte : ');
readln(coven);
eliminar(coven);
end;
#53 : begin
clrscr;
ordenararray;
mostrarorden;
end;
#54 : begin clrscr; contadores; end;
#55 : sas := true;
end;
until sas = true;
end;
begin
cont := 0;
menu;
end.
Valora esta pregunta


0