Pascal/Turbo Pascal - problemas con vector

 
Vista:

problemas con vector

Publicado por juan (1 intervención) el 22/07/2013 15:47:49
se tiene almacenado en la memoria de dos vectores M y N de cien elementos cada uno. hacer un algoritmo que escriba la palabra " iguales" si ambos vectores son iguales y "diferentes" si no lo son.
serán iguales cuando en la misma posición de ambos vectores se tenga el mismo valor para todos los elementos
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

problemas con vector

Publicado por ramon (2158 intervenciones) el 23/07/2013 22:17:40
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
{A ver si esto ayuda}
 
 program s2arrays;
 uses
    crt;
  const
     nuvec = 100;
  type
    vect = array[1..nuvec] of integer;
 
  var
    vector1, vector2 : vect;
    di, cont : integer;
 
 
    procedure rellenavectores(como : boolean);
    var
      t, d : integer;
      vali : boolean;
    begin
       randomize;
       cont := 1;
       vali := true;
       repeat
           d := random(119) + 1;
           for t := 1 to nuvec do
           if vector1[t] = d then
           vali := false;
           if vali = true then
           begin
              vector1[cont] := d;
              if como = true then
              vector2[cont] := d
            else
              begin
              if cont in[10,22,55,67,82] then
              vector2[cont] := d + 6
           else
              vector2[cont] := d;
              end;
              d := 0;
              cont := cont + 1;
           end;
           vali := true;
       until cont > nuvec;
    end;
 
   function soniguales(v1, v2 : vect;var nn : integer) : boolean;
   var
     u : integer;
   begin
      nn := 0;
      soniguales := true;
      for u := 1 to nuvec do
      if v1[u] <> v2[u] then
      begin
      soniguales := false;
      nn := nn + 1;
      end;
   end;
 
  procedure menu;
  var
    sal : boolean;
    tec : char;
   begin
      sal := false;
    repeat
       clrscr;
       writeln('**** Menu General ****');
       writeln;
       writeln('   1 = Si Iguales');
       writeln('   2 = No Iguales');
       writeln('   3 = Salir');
       repeat
           tec := readkey;
       until tec in['1','2','3'];
       clrscr;
   case tec of
  '1' : rellenavectores(true);
  '2' : rellenavectores(false);
  '3' : sal := true;
   end;
    if tec in['1','2'] then
    begin
       if soniguales(vector1, vector2, di) = true then
       writeln('  Los Vectores Son Iguales')
    else
       writeln('  Los Vectores No Son Iguales Diferencias : ',di);
       writeln;
       writeln('  Los Vectores N1 ');
       for cont := 1 to nuvec do
       begin
         write('   ',vector1[cont]);
       end;
        writeln;
        writeln('  Los Vectores N2 ');
        for cont := 1 to nuvec do
        begin
        write('   ',vector2[cont]);
       end;
       writeln;
       writeln('  >>> Pulse Una Tecla <<< ');
       readkey;
     end;
    until sal = true;
   end;
 
 
  begin
     clrscr;
     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
0
Comentar