Pascal/Turbo Pascal - Ayuda con este programa

 
Vista:
sin imagen de perfil

Ayuda con este programa

Publicado por Luis (14 intervenciones) el 23/06/2015 20:49:21
buenas tardes amigo necesito ayuda con estos dos programas necesito saber como hacerlo

1) Realice un procedimiento llamado 'acadena' que reciba como primer parámetro un
entero largo (longint) y que tenga un segundo parámetro (por referencia) tipo
cadena en el cual guardará el número recibido pero en formato cadena.

ese es uno

y este es el otro programa

2) Elabore una función que reciba una cadena (cuyo formato debe ser un número
binario, es decir, sólo ceros y unos) y retorne un entero largo con el número binario
ya convertido.

y este es otro

3) Elabore una función que reciba un número entero y retorne un booleano que
indique si el número es capicúo o no.

y este es otro

4) Elabore una función que reciba un número entero y retorne un valor
lógico(booleano) que indique si el número es primo o no.

como puedo hacer esso tres programas
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 este programa

Publicado por ramon (2158 intervenciones) el 24/06/2015 23:30:33
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
{A ver si esto ayuda}
 
 program numeros;
  uses
     crt;
   var
     referenc : string;
     longi : longint;
     nut : integer;
 
    procedure convernumcade(n : longint; var refe : string);
    begin
       str(n,refe);
    end;
 
    function binaentero(bina : string) : longint;
    const
       binari : Array [1..16] of longint =
       (32768,16384,8192,4096,2048,1024,512,256,128,64,32,16,8,4,2,1);
     var
       r, h, nume : longint;
    begin
     nume := 0;
     r := 1;
     for h := length(bina) downto 1 do
     begin
         If bina[h] = '1'  then
            nume := nume + binari[17 - r];
            r := r + 1;
     end;
        binaentero := nume;
    end;
 
    function numerocapic(n : integer) : boolean;
    var
       comp, part, elnum : string;
       y, p : integer;
    begin
       str(n,elnum);
       if length(elnum) > 1 then
       begin
       if length(elnum) mod 2 = 0 then
       begin
       part := copy(elnum,(length(elnum) div 2) + 1,length(elnum));
       delete(elnum,(length(elnum) div 2) + 1,length(elnum));
       y := 1;
       for p := length(part) downto 1 do
       begin
          comp[y] := part[p];
          comp[0] := chr(y);
          y := y + 1;
       end;
         if elnum = comp then
         numerocapic := true
      else
         numerocapic := false;
     end;
     if length(elnum) mod 2 <> 0 then
     begin
        part := copy(elnum,(length(elnum) div 2) + 2,length(elnum));
        delete(elnum,(length(elnum) div 2) + 1,length(elnum));
        y := 1;
       for p := length(part) downto 1 do
       begin
          comp[y] := part[p];
          comp[0] := chr(y);
          y := y + 1;
       end;
         if elnum = comp then
         numerocapic := true
      else
         numerocapic := false;
     end;
    end;
   end;
 
   function esprimo(n : integer) : boolean;
   var
      rest, prim, ye : integer;
   begin
      prim := 0;
      rest := 0;
      ye := n div 2;
     while ye <> 1 do
     begin
       rest := n mod ye;
       if rest = 0 then
       prim := prim + 1;
       ye := ye - 1;
      end;
     if prim = 0 then
     esprimo := true
  else
     esprimo := false;
   end;
 
    begin
       clrscr;
       writeln;
       writeln('   Num a Cadena ');
       write('  Entre Numero : ');
       readln(longi);
       convernumcade(longi,referenc);
       writeln('  La Cadena Es = ',referenc);
       writeln;
       writeln('   Valor Num Binario ');
       write('   Entre Num. Binario 1 a 16 Digitos : ');
       readln(referenc);
       writeln('   El Numero Es =  ',binaentero(referenc));
       writeln;
       writeln('   Capicua ');
       write('  Entre Numero : ');
       readln(nut);
       writeln('   ',numerocapic(nut));
       writeln;
       writeln('   Num Primo ');
       write('  Entre Numero : ');
       readln(nut);
       writeln('   ',esprimo(nut));
       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