Pascal/Turbo Pascal - deberá informar si son correlativos

 
Vista:

deberá informar si son correlativos

Publicado por Luisina Hernández (1 intervención) el 14/06/2021 02:57:40
Ayuda porfavor! En pascal
Hacer un programa que permita cargar 5 valores numéricos, el mismo deberá informar si son correlativos.
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

deberá informar si son correlativos

Publicado por ramon (2158 intervenciones) el 14/06/2021 22:50:20
Espero esto te sirva.

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
procedure entranumeros;
  begin
     h := 1;
     writeln(' Entre 5 valores numericos ');
     writeln;
   repeat
     write(' Entre N§ ',h,' : ');
     readln(nume[h]);
     h := h + 1;
   until h > 5;
   nume[0] := h - 1;
  end;
 
  function correlativos : boolean;
  var
    aux : integer;
   begin
      correlativos := true;
      for h := 1 to nume[0] - 1 do
       for t := nume[0] downto h + 1 do
       if nume[h] > nume[t] then
       begin
          aux := nume[t];
          nume[t] := nume[h];
          nume[h] := aux;
       end;
       aux := nume[1];
       for t := 2 to nume[0] do
       if aux + 1 = nume[t] then
       aux := nume[t]
     else
       correlativos := false;
   end;
 
 
   begin
      clrscr;
      entranumeros;
      writeln(' Son Correlativos = ',correlativos);
      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