Pascal/Turbo Pascal - Ayuda con Colas en pascal

 
Vista:

Ayuda con Colas en pascal

Publicado por pamela gomez (17 intervenciones) el 19/09/2012 03:34:02
hola necesito un programa q haga la labor de una cola(FIFO:el primero q entra ese el primero en salir),el programa tiene q tener un menu:1.insertar datos: en este se inserta los datos llenando un vector, 2.Procesar datos:aqui se puede hacer cualquier calculo(ejm:una suma)y q se vaya vaciando el vector 3.Mostra: aqui se muestra el resultado de procesar los datos y 4.salir.
Esto es lo q necesito que haga el programa les agradeceria su ayuda, d antemano les doy las gracias por su colaboracion.
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 Colas en pascal

Publicado por pamela gomez (17 intervenciones) el 20/09/2012 06:37:12
por favor alguien q me ayude o porlo menos me de una idea pequeña d como empezar con el codigo.Gracias
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

Ayuda con Colas en pascal

Publicado por ramon (2158 intervenciones) el 21/09/2012 16:41:43
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
{Espero esto te ayude }
 
 program pilafifo;
 uses
    crt;
 type
    pfifo = ^rfifo;
    rfifo = record
    dato : integer;
    sig  : pfifo;
    end;
 
  var
    prim, ultim, actu : pfifo;
    regfi : rfifo;
 
 
    function entrada : integer;
    var
       num : integer;
    begin
        num := 0;
        clrscr;
        write('   Entre N§ : ');
        readln(num);
        entrada := num;
    end;
 
   procedure inicionil;
   begin
       prim := nil;
       ultim := nil;
   end;
 
   procedure crearinserta;
   begin
       new(actu);
       actu^.dato := entrada;
       actu^.sig := nil;
       if ultim <> nil then
       begin
          ultim^.sig := actu;
          ultim := actu;
       end
    else
       begin
          prim := actu;
          ultim := actu;
       end;
    end;
 
    procedure borradofifo;
    var
      punt, borra : pfifo;
    begin
        if prim = ultim then
        begin
           borra := prim;
           dispose(borra);
           prim := nil;
           ultim := nil;
        end
     else
        begin
           borra := prim;
           prim := borra^.sig;
           dispose(borra);
        end;
    end;
 
    procedure muestrafifo;
    var
      punt : pfifo;
    begin
     punt := prim;
    while punt <> nil do
    begin
       write('   ',punt^.dato);
       punt := punt^.sig;
    end;
      readkey;
  end;
 
  procedure suma;
  var
    sum : integer;
    punt : pfifo;
  begin
      write(' Sumar El Primero Por N§ : ');
      readln(sum);
      punt := prim;
      writeln('  La Suma De [ ',sum,' ] Y [ ',punt^.dato,' ] Es : ',
                                   Sum + punt^.dato);
      writeln;
      writeln('  Pulse Una Tecla');
      readkey;
      borradofifo;
  end;
 
  procedure Resta;
  var
    res : integer;
    punt : pfifo;
  begin
      write(' Restar El Primero Del N§ : ');
      readln(res);
      punt := prim;
      writeln('  La Resta De [ ',punt^.dato,' ] Y [ ',res,' ] Es : ',
                                    punt^.dato - res);
      writeln;
      writeln('  Pulse Una Tecla');
      readkey;
      borradofifo;
  end;
 
  procedure multiplica;
  var
     mul : integer;
     punt : pfifo;
    begin
      write(' La Multiplicacion Del Primero Por N§ : ');
      readln(mul);
      punt := prim;
      writeln('  La Multiplicacion De [ ',punt^.dato,' ] Y [ ',mul,' ] Es : ',
                                   punt^.dato * mul);
      writeln;
      writeln('  Pulse Una Tecla');
      readkey;
      borradofifo;
   end;
 
   procedure division;
   var
     divi : integer;
     punt : pfifo;
    begin
      write(' La Division Del Primero Por N§ : ');
      readln(divi);
      punt := prim;
      writeln('  La Division De [ ',punt^.dato,' ] Y [ ',divi,' ] Es : ',
                                   punt^.dato / divi:0:2);
      writeln;
      writeln('  Pulse Una Tecla');
      readkey;
      borradofifo;
   end;
 
  procedure procesodedatos;
  var
     te : char;
     fuera : boolean;
  begin
    fuera := false;
    repeat
      clrscr;
      writeln(' **** Procesos a Elejir ****');
      writeln;
      writeln('  [S] = Sumar');
      writeln('  [R] = Restar');
      writeln('  [M] = Multiplicar');
      writeln('  [D] = Dividir');
      writeln('  [F] = Salir');
      writeln;
      writeln('  <<< Elija Opcion >>>');
      te := upcase(readkey);
   case te of
 'S' : begin clrscr; suma; end;
 'R' : begin clrscr; Resta; end;
 'M' : begin clrscr; multiplica; end;
 'D' : begin clrscr; division; end;
 'F' : fuera := true;
  end;
    until fuera = true;
  end;
 
  procedure menu;
  var
    tec : char;
    sal : boolean;
  begin
      sal := false;
    repeat
    clrscr;
    writeln('  ***** Menu Principal *****');
    writeln;
    writeln('  1 = Crear O Insertar En Cola');
    writeln('  2 = Mostrar Todos');
    writeln('  3 = Procesar Datos');
    writeln('  4 = Borrar Primer Elemento');
    writeln('  F =  Salir');
    writeln;
    writeln('  <<< Elija Opcion >>>');
    tec := upcase(readkey);
  case tec of
 '1' : begin  clrscr; crearinserta; end;
 '2' : begin  clrscr; muestrafifo; end;
 '3' : begin  clrscr; procesodedatos; end;
 '4' : begin  clrscr; borradofifo; end;
 'F' : sal := true;
  end;
    until sal = true;
  end;
 
 
   begin
      inicionil;
      menu;
      if prim <> nil then
      dispose(actu);
   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

Ayuda con Colas en pascal

Publicado por pamela gomez (17 intervenciones) el 22/09/2012 05:59:05
muchas gracias por su ayuda si me sirvio
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