Pascal/Turbo Pascal - [AYUDA] Problema con el Ejercicio

 
Vista:
Imágen de perfil de Leo G.

[AYUDA] Problema con el Ejercicio

Publicado por Leo G. (11 intervenciones) el 01/10/2014 18:57:23
Hola! tengo esta consigna y no se como hacer que ande.

Estoy trabajando con array no mas, y no uso reccord.

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

Y tengo esto hecho.
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
Program Alumnos;
	Uses crt;
	CONST
		N = 5;
 
	Type
		 estudiante = array [1 .. N] of string;
	Var
		Es : estudiante;
		opcion, Limite: Integer;
		lista : string;
 
	Procedure Carga (var es : estudiante; limite : Integer); {Se realiza la carga de la información}
		Var
			I : Integer;
		Begin
			For I := 1 to limite do
				Begin
					write (I,'_ '); {Hace una forma mas amigable con el usuario a la hora de ingresar la info}
					readln (es[I]);
				End;
		End;
 
	Procedure Insercion (Var es: estudiante);
		Var
			i,j: integer;
			aux1,aux2:string;
		Begin
			For i:=1 to N DO
				For j:=1 to N DO
					begin
						If es[j] > es[j+1] then
							begin
								aux1:=es[j];
								aux2:=es[j+1];
								es[j]:=aux2;
								es[j+1]:=aux1;
							end;
					end;
		End;
 
	Procedure Burbuja (var es:estudiante);
		Var
			i, j: Integer;
			aux: string;
		Begin
			For i := 1 to n-1 do
				For j:= 1 to n-1 do
					Begin
						If es[j] > es [j+1] then
							Begin
								aux := es[j+1];
								es[i] := es[j+1];
								es [j+1] := aux;
							end;
					End;
		End;
 
 
BEGIN
        Limite := N;
	repeat
	clrscr;
	writeln('Ingrese la Opcion que desea ejecutar.'); {Hace una forma mas amigable con el usuario al momento de ver en pantalla}
		writeln;
		writeln (' Opcion 1 = Inicializar el Vector.');
		writeln (' Opcion 2 = Ordenamiento del Vector Con Metodo de Burbuja.');
		writeln (' Opcion 3 = Impresion del vector del metodo ante usado.');
		writeln (' Opcion 4 = Ordenamiento del Vector con Metodo de Insercion.');
		writeln (' Opcion 5 = Impresion del vector del metodo ante usado.');
		writeln (' Opcion 6 = Salir del Menu.');
		writeln;
		readln (opcion);
		writeln;
	case opcion of
			1:
				begin
					writeln ('Ingrese los Apellidos y Nombre de los Alumnos: ');
					Carga (Es, Limite);
					readln (lista);
 
				End;
			2:
				Begin
					readln (lista);
						Begin
							Burbuja (Es);
						end;
 
				End;
			3:
				Begin
					writeln ('Vector ingresado es el siguiente:');
					writeln (lista);
					writeln ('Vector Ordenado:');
					writeln ();
				End;
			4:
				Begin
					readln (lista);
						Insercion (Es);
				End;
			5:
				Begin
					writeln ('Vector ingresado es el siguiente:');
					writeln (lista);
					writeln ('Vector Ordenado:');
					writeln ();
				End;
			6:
				Begin
					writeln('Ha decidido salir del sistema');
				End;
		else
			writeln('OPCION NO RECONOCIDA');
		end;
until opcion = 6;
END.

Desde Ya Gracias. Si puede ser cuanto ante mejor.
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] Problema con el Ejercicio

Publicado por ramon (2158 intervenciones) el 02/10/2014 19:01:12
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
{A ver si esto te ayuda}
 
Program Alumnos;
 Uses
    crt;
    CONST
       N = 5;
 
    Type
      estudiante = array[1..N] of string;
 
    Var
       Es : estudiante;
       opcion, Limite : Integer;
       lista : string;
 
 procedure entrada_estudiantes(var st : estudiante);
 begin
    if limite = 0 then
    limite := 1;
    if limite - 1 >= N then
    begin
       clrscr;
       writeln('  El Vector Esta Lleno');
       writeln;
       writeln('  Pulse Una Tecla');
       readkey;
    end
  else
    begin
    repeat
        clrscr;
        writeln('   Finaliza Con [Santander Lucas] o Entrada > N');
        writeln;
        write('   Entrada Num. ',limite,' : ');
        readln(lista);
        if lista <> 'Santander Lucas' then
        begin
        st[limite] := lista;
        limite := limite + 1;
        end;
    until (limite > n) or (lista = 'Santander Lucas');
    end;
  end;
 
  procedure Ordenacion_burbuja(var ob : estudiante);
  var
    i, g : integer;
    temp : string;
    begin
       if limite > 2 then
       begin
          for i := 1 to limite - 1 do
           for g := limite - 1 downto i + 1 do
           if ob[i] > ob[g] then
           begin
              temp := ob[i];
              ob[i] := ob[g];
              ob[g] := temp;
           end;
       end;
    end;
 
   procedure muestra_vector(bt : estudiante);
   var
     v : integer;
   begin
      if limite > 0 then
      begin
      writeln('   ****> El Contenido Del Vector Es <****');
      writeln;
      for v := 1 to limite - 1 do
      begin
         writeln('   ',bt[v]);
      end;
      writeln;
      writeln('    Pulse Una Tecla');
      readkey;
    end
 else
     begin
        clrscr;
        writeln('  El Vector Esta Vacio Pulse Una Tecla');
        readkey;
     end;
   end;
 
   procedure Ordenacion_insercion(var is : estudiante);
   var
     s, r : integer;
     temp : string;
    begin
       if limite - 1 > 1 then
       begin
          for s := 2 to limite - 1 do
           begin
              temp := is[s];
              r := s - 1;
              while (r >= 1) and (temp < is[r]) do
              begin
                  is[r + 1] := is[r];
                  r := r - 1;
              end;
                is[r + 1] := temp;
           end;
       end;
    end;
 
 
  procedure menu;
  var
    sal : boolean;
    tecla : char;
   begin
      sal := false;
   repeat
       clrscr;
       writeln('    ***** Menu Jeneral *****');
       writeln;
       writeln('    1 = Entrada Estudiantes');
       writeln('    2 = Ordenacion Burbuja');
       writeln('    3 = Muestra Vector ingresado');
       writeln('    4 = Ordenacion Insercion');
       writeln('    5 = Salir');
       writeln;
       writeln('    >>>> Elija Opcion <<<<');
       repeat
          tecla := readkey;
       until tecla in['1','2','3','4','5'];
       clrscr;
     case tecla of
  '1' : entrada_estudiantes(es);
  '2' : Ordenacion_burbuja(es);
  '3' : muestra_vector(es);
  '4' : Ordenacion_insercion(es);
  '5' : sal := true;
     end;
   until sal = true;
  end;
 
  begin
      limite := 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