Pascal/Turbo Pascal - Ayuda con punteros

 
Vista:

Ayuda con punteros

Publicado por jorge (5 intervenciones) el 15/02/2016 09:21:03
alguien sabe hacer este ejercicio con 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
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
program tope;
uses crt;
const max=5;
type
alum=record
	tope:byte;
	end;
 
 
procedure inicializa(var info:alum);
 
	begin
			info.tope:=0;
	end;
 
 
function lleno (info:alum):boolean;
	begin
		lleno:=false;
		if info.tope=max then begin
			lleno:=true;
		end;
	end;
 
function vacio(info:alum):boolean;
	begin
		vacio:=false;
		if info.tope=0 then begin
			vacio:=true;
		end;
	end;
 
procedure entrada (var info:alum);
var
	ok:boolean;
	begin
	clrscr;
	ok:=lleno(info);
		if ok=true then begin
			write('Esta llena'); repeat until keypressed
		end
		else begin
			write('Dato entrado'); repeat until keypressed;
			inc(info.tope);
 
		end;
	end;
procedure listado(info:alum);
var
	ok2:boolean;
	begin
	clrscr;
	ok2:=vacio(info);
		if ok2=true then begin
				write('Esta vacio'); repeat until keypressed
		end
		else begin
			write('Datos en la lista');repeat until keypressed;
			inc(info.tope);
		end;
	end;
 
 
 
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

Ayuda con punteros

Publicado por ramon (2158 intervenciones) el 05/03/2016 12:59:05
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
139
{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