Pascal/Turbo Pascal - punteros

 
Vista:

punteros

Publicado por kbyo (5 intervenciones) el 15/02/2016 10:33:23
ejercicio 1 local --> entrada listado fin , entrada hasta que este lleno y listarno, autilizacion punteros

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
program puntero_basico;
uses crt;
	type
				cad=string[20];
				num=array[1..3] of string;
				puntero=^integer;
				puntero1:=^cad;
				num1=^num;
 
					var
		punt:^registro;
		op:char;
 
 
 
procedure menu;
		begin
			clrscr;
			writeln('1.-Entrada :');
			writeln('2.-Listado :');
			writeln('3.-Fin     :');
			write('Dar opcion : ');
		end;
 
var info:alum;
	op:char;
 
begin
inicializa(info);
repeat
menu;
op:=readkey;
 case op of
      '1':entrada(info);
      '2':listado(info);
     end;
until op='3';
end.
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

punteros

Publicado por ramon (2158 intervenciones) el 05/03/2016 12:55:32
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
{mira esto}
 program tope;
  uses
     crt;
   const
     max = 5;
 type
    palum = ^alum;
    alum = record
	tope : byte;
         sig : palum;
	end;
 
 var
   prim, actu, ulti : palum;
   dat : alum;
   cont : integer;
 
  procedure entrar(info : alum);
  begin
     if prim = nil then
     begin
        new(actu);
        actu^.tope := info.tope;
        prim := actu;
        actu^.sig := nil;
     end
   else
      begin
         ulti := actu;
         new(actu);
         actu^.tope := info.tope;
         ulti^.sig := actu;
         actu^.sig := nil;
      end;
      cont := cont + 1;
  end;
 
  procedure inicializa(var info:alum);
  begin
     fillchar(info,sizeof(info),0);
     prim := nil;
     cont := 0;
  end;
 
 
  function lleno(mx : integer) : boolean;
  begin
    lleno := false;
    if mx >= max then
    begin
      lleno := true;
    end;
  end;
 
  function vacio(mn : integer) : boolean;
  begin
     vacio := false;
     if mn <= 0 then
     begin
       vacio := true;
     end;
  end;
 
  procedure entrada(info : alum);
  var
    ok1 : boolean;
  begin
     clrscr;
     ok1 := lleno(cont);
     if ok1 = true then
     begin
        writeln('      Esta llena');
        writeln('   Pulse Una Tecla');
        readkey;
     end
  else
     begin
       write('Dato entrado : ');
       readln(info.tope);
       entrar(info);
       end;
  end;
 
 
    procedure listado;
    var
      ok2 : boolean;
      temp : palum;
      begin
	  clrscr;
	   ok2 := vacio(cont);
	   if ok2 = true then
           begin
	      writeln('   Esta vacio');
              writeln('   Pulse Una Tecla');
              readkey;
	   end
      else
          begin
            temp := prim;
          while temp <> nil do
          begin
             writeln(temp^.tope);
             temp := temp^.sig;
          end;
            readkey;
	  end;
    end;
 
 
 
   procedure menu;
   var
     op : char;
   begin
   repeat
     clrscr;
     writeln('   1.- Entrada :');
     writeln('   2.- Listado :');
     writeln('   3.- Fin     :');
     write('   Dar opcion : ');
     repeat
        op := readkey;
     until op in['1','2','3'];
     case op of
  '1':entrada(dat);
  '2':listado;
     end;
   until op = '3';
   end;
 
 
 
  begin
     inicializa(dat);
     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