Pascal/Turbo Pascal - Indicar si dos vectores son iguales

 
Vista:

Indicar si dos vectores son iguales

Publicado por andrea (4 intervenciones) el 14/07/2015 16:43:50
se tienen almacenados dos vectores A Y B con 100 elementos cada uno,
crear un programa que diga si ambos vectores son iguales o no lo son.

Nesecito ayuda por fabor.
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
sin imagen de perfil

Indicar si dos vectores son iguales

Publicado por David (224 intervenciones) el 14/07/2015 17:41:58
Te propongo la siguiente solución:

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
Uses CRT;
 
Const
  TOPE = 100;
 
Type
  TipoVector = Array [1..TOPE] OF INTEGER;
 
VAR
  v1,v2:tipoVector;
  igual:boolean;
  i:integer;
 
 
BEGIN
   clrscr;
   igual:=true;
   for I:=1 to tope do
     if v1[i]<>v2[i] then
          begin
            igual:=false;
            break;
          end;
  if igual=true then
    writeln('Ambos vectores son iguales')
  else
    writeln('Son diferentes');
  readln;
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
sin imagen de perfil
Val: 36
Ha aumentado su posición en 4 puestos en Pascal/Turbo Pascal (en relación al último mes)
Gráfica de Pascal/Turbo Pascal

Indicar si dos vectores son iguales

Publicado por Armando Fuenmayor (43 intervenciones) el 15/07/2015 21:55:52
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
uses crt;
    const
     TOPE = 3;
    type
       TipoVector = Array [1..TOPE] OF INTEGER;
 
  function soniguales(a,b : tipoVector ; nu :integer ): boolean ;
   var
       y      : integer ;
       igual  : boolean ;
    begin
 
     igual := true ;
     for y := 1 to nu do
     begin
       if (a[y] <> b[y]) then
       begin
         igual :=  false ;
       end;
       soniguales := igual ;
     end;
   end;
 
    var
      v1 , v2  : tipoVector ;
          i    : integer    ;
          car  : char       ;
   BEGIN
   clrscr;
 
 (** Cargar el primer vector *****)
 
  for I:=1 to tope do
  begin
   writeln('Lea los numeros del primer Vector N§ ',i );
   read(v1[i]);
  end;
       writeln;
       writeln;
(***********)
   for I:=1 to tope do
  begin
   writeln('Lea los numeros del segundo Vector N§',i );
   read(v2[i]);
  end;
 
   writeln;
   writeln;
   writeln('El primer Vector:');
  for I:=1 to tope do
  begin
    write(v1[i]:5);
  end;
 
 
   writeln;
   writeln;
   writeln('El segundo Vector:');
  for I:=1 to tope do
  begin
    write(v2[i]:5);
  end;
    writeln;
    writeln;
 
    if (soniguales(v1,v2, TOPE))   then
    begin
      write('los dos vectores son iguales')
    end
    else
    begin
      write('los dos vectores no son iguales')
    end;
          car := 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