Pascal/Turbo Pascal - Ayuda con un Ejercicio

 
Vista:
Imágen de perfil de Leo

Ayuda con un Ejercicio

Publicado por Leo (11 intervenciones) el 23/09/2013 18:18:28
Hola me pueden ayudar con este ejercicio. Que estuve una semana intentando resolver y no puedo.

Se leen apellidos y nombres de alumnos de Algoritmo y Estructura de Datos y se los almacena en un vector. Los datos terminan con apellido y nombre igual a ‘Santander', 'Lucas’. Se pide imprimir un listado ordenado alfabéticamente.
A) Utilice el método de ordenación de Burbuja.
B) Utilice el método de ordenación de Inserción.

Desde muchas gracias.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Ayuda con un Ejercicio

Publicado por ramon (2158 intervenciones) el 24/09/2013 11:37:25
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
{Esto Te sirve}
 
 program ordenacion;
 uses
   crt;
 
  type
    datosalumno = record
          apellido : string[30];
          nombre   : string[30];
        end;
 
  const
     apelli : string[30] = 'Santander';
     nomb : string[30] = 'Lucas';
     tarray : longint = (64000 div sizeof(datosalumno));
 
  var
    datos : array[1..(64000 div sizeof(datosalumno))] of datosalumno;
    entradas : integer;
 
   procedure entrada_datos;
   var
     nn : integer;
     tc : char;
   begin
        nn := 1;
        while (datos[nn].apellido <> apelli) and (datos[nn].nombre <> nomb) do
        begin
        clrscr;
        writeln('**** Entrada Datos Alumnos ****');
        writeln;
        write('  Apellido : ');
        readln(datos[nn].apellido);
        write('  Nombre   : ');
        readln(datos[nn].nombre);
        if (datos[nn].apellido <> apelli) and (datos[nn].nombre <> nomb) then
        nn := nn + 1;
      end;
      entradas := nn - 1;
      clrscr;
   end;
 
  procedure ordena(forma : char);
  var
    temp : datosalumno;
    t, i : word;
    begin
       writeln('>>>>>> Ordenando Array >>>>>>>');
       if upcase(forma) = 'B' then
       begin
        for i := 1 to entradas do
          for t := entradas downto i + 1 do
          begin
             if datos[i].nombre > datos[t].nombre then
             begin
                temp := datos[i];
                datos[i] := datos[t];
                datos[t] := temp;
             end;
          end;
       end;
       if upcase(forma) = 'I' then
       begin
           for i := 2 to entradas do
           begin
              temp := datos[i];
              t := i - 1;
              while (t >= 1) and (temp.nombre < datos[t].nombre) do
              begin
                  datos[t + 1] := datos[t];
                  t := t - 1;
              end;
                datos[t + 1] := temp;
           end;
      end;
         delay(200);
    end;
 
   procedure presentadatos;
   var
     d : integer;
    begin
    for d := 1 to entradas do
    begin
   writeln(' Nombre : ',datos[d].nombre,'    Apellido : ',datos[d].apellido);
    end;
    writeln;
    writeln('>>>>>> Pulse Una Tecla <<<<<<');
    readkey;
  end;
 
  procedure menu;
  var
     salir : boolean;
     tec : char;
  begin
     salir := false;
   repeat
      clrscr;
      writeln('     ***** Menu General ***** ');
      writeln;
      writeln('     1 : Entrada Datos');
      writeln('     2 : Presentacion De Entradas');
      writeln('     3 : Ordenacion Burbuja');
      writeln('     4 : Ordenacion Insercion');
      writeln('     5 : Salir');
      writeln;
      writeln('     <<<<< Elija Opcion >>>>>');
      repeat
          tec := readkey;
      until tec in['1','2','3','4','5'];
      clrscr;
   case tec of
 '1' : entrada_datos;
 '2' : begin
       if entradas > 0 then
       begin
       presentadatos;
       end
     else
        begin
        writeln('**** No Existen Datos Actual Mente Pulse Una Tecla ****');
        readkey;
        end;
       end;
 '3' : begin
       if entradas > 0 then
       begin
         ordena('B');
       end
     else
        begin
        writeln('**** No Existen Datos Actual Mente Pulse Una Tecla ****');
        readkey;
        end;
       end;
 '4' : begin
       if entradas > 0 then
       begin
         ordena('I');
       end
     else
        begin
        writeln('**** No Existen Datos Actual Mente Pulse Una Tecla ****');
        readkey;
        end;
       end;
 '5' : salir := true;
   end;
   until salir = true;
  end;
 
 
 
 
  begin
     clrscr;
     entradas := 0;
     menu;
  end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
Imágen de perfil de Leo

Ayuda con un Ejercicio

Publicado por Leo (11 intervenciones) el 24/09/2013 23:05:39
Muchas Gracias. Me re sirvió.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar