Pascal/Turbo Pascal - Ayuda con matrices URGENTE!!

 
Vista:

Ayuda con matrices URGENTE!!

Publicado por JuanP (20 intervenciones) el 17/06/2013 17:31:13
Tengo que ordenar los planos de una matriz de forma ascendente de acuerdo a la cantidad de ceros de cada plano, sin utilizar estructuras auxiliares (matrices y arreglos). La funcion para contar los ceros del plano ya la tengo, les agradeceria una ayuda para ordenar los planos
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 matrices URGENTE!!

Publicado por ramon (2158 intervenciones) el 19/06/2013 13:05:10
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
{A ver si esto te ayuda}
 
program arrays;
 uses
     crt;
    const
       matriz = 8;
    type
    matrizd = array[1..matriz] of byte;
 
  var
  reserva : matrizd;
  lamatriz : array[1..matriz] of matrizd;
  d, t, r : integer;
 
  procedure rellena;
  var
     r1, r2 : integer;
  begin
     randomize;
     for r1 := 1 to matriz do
       for r2 := 1 to matriz do
       begin
           lamatriz[r1][r2] := random(2);
       end;
  end;
 
  procedure ordena;
  var
     cont1, cont2 : integer;
  begin
 for t := 1 to matriz do
   for r := matriz downto t + 1 do
   begin
     cont1 := 0;
     cont2 := 0;
     for d := 1 to matriz do
     begin
         if lamatriz[t][d] = 0 then
         cont1 := cont1 + 1;
         if lamatriz[r][d] = 0 then
         cont2 := cont2 + 1;
     end;
   if cont1 > cont2 then
   begin
   reserva := lamatriz[t];
   lamatriz[t] := lamatriz[r];
   lamatriz[r] := reserva;
   end;
  end;
 end;
 
 
  begin
      clrscr;
      rellena;
      for t := 1 to matriz do
      begin
        for r := 1 to matriz do
        begin
        write(' ',lamatriz[t][r]);
        end;
        writeln;
        end;
        ordena;
        writeln;
        for t := 1 to matriz do
      begin
        for r := 1 to matriz do
        begin
        write(' ',lamatriz[t][r]);
        end;
        writeln;
        end;
        readkey;
  end.
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