Pascal/Turbo Pascal - calendariooo AYUDAA!!

 
Vista:
sin imagen de perfil

calendariooo AYUDAA!!

Publicado por Julieta (9 intervenciones) el 14/10/2016 20:02:49
no me da el archivo (tengo que crearlo yo) y el enunciado es este.
PARA GENERAR UN NUEVO MES EN CALENDARIOS.DAT, SE DEBE VERIFICAR CUAL ES EL ULTIMO MES REGISTRADO Y DE ESA FORMA SE GENERARA EL PROXIMO (EJEMPLO MES12 Y AÑO=2016 - MES=1 Y AÑO2017) CON TODOS LOS ESPACIOS RESERVADOS PARA LOS NOMBRES DE LAS MASCOTAS EN BLANCO. SI ES LA PRIMERA CARGA, DEBEN DECIDIR EN QUE MES Y AÑO COMIENZA.


la cuadrila es en las columnas es de 1 a 25 y las filas irian los dias de cada mes .. no se como crear el calendario, ni la matriz
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

calendariooo AYUDAA!!

Publicado por ramon (2158 intervenciones) el 17/10/2016 22:30:44
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
{Mira a ver si esto te ayuda sino dímelo y me ajustare mas a lo que pides}
 
 program elcalebdario;
  uses
    crt, dos;
 
    const
     mesesbi : array[1..12] of word = (31, 29, 31, 30, 31, 30, 31, 31, 30,
                                                       31, 30, 31);
     meses : array[1..12] of word = (31, 28, 31, 30, 31, 30, 31, 31, 30,
                                                       31, 30, 31);
     diadesemana : array[0..6] of string[12] = ('Domingo','Lunes',
     'Martes','Miercoles','Jurves','Viernes','Savado');
     elmes : array[1..12] of string[18] = (
     'Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto',
     'Setiembre','Octubre','Noviembre','Diciembre');
     nombre : string = 'Calendario.dat';
 
   type
     archivo = record
           mestom : string[12];
           ayotom : word;
           diatom : array[1..31] of char;
         end;
 
 
 
    var
    f : file of archivo;
    dato : archivo;
    ayo, mes, dia, diase : word;
    actual, mesant, diaant, posterior : word;
    faltan : word;
    u : integer;
    regs : registers;
    diasem : string[12];
 
  function bisiesto(ano3 : word) : boolean;
  var
     bb, bx, by : real;
  begin
     bx := frac(ano3/4);
     by := frac(ano3/100);
     bb := frac(ano3/400);
     if ((bx = 0) and (by > 0)) or ((bx = 0) and (bb = 0)) then
     bisiesto := true
   else
     bisiesto := false;
  end;
 
   function eldiaes(d, m, a : word): integer;
   var
     r, p : word;
      begin
        if (m <= 2) then begin
        m := m + 10;
        a := a - 1;
     end
  else
     m := m - 2;
     r := a mod 100;
     p := a div 100;
     eldiaes := (700 + ((26 * m - 2) div 10) + d + r + r div 4 +
                                             p div 4 - 2 * p) mod 7
   end;
 
  function fechaactual : string;
  var
    aa, mm, dd : string[4];
    date : string;
  begin
    regs.ah := $2a;
    with regs do
    intr($21,regs);
    with regs do
     begin
     str(cx ,aa);
     str(dh ,mm);
     str(dl,dd);
   end;
    date := dd + '/' + mm + '/' + aa;
    fechaactual := copy(date,1,length(date));
  end;
 
  procedure tomafecha(var d, m, a : word);
  var
    error, t, i : integer;
    fech : string;
    dd, mm : string[2];
    aa : string[4];
  begin
     t := 1;
     fech := fechaactual;
     for i := 1 to length(fech) do
     begin
     if fech[i] <> '/' then
     if i in[1,2] then
     begin
     dd[t] := fech[i];
     dd[0] := chr(t);
     t := t + 1;
     end;
     if i in[3,6] then
     t := 1;
     if i in[4,5] then
     begin
        mm[t] := fech[i];
        mm[0] := chr(t);
        t := t + 1;
     end;
     if i in[7,8,9,10] then
     begin
        aa[t] := fech[i];
        aa[0] := chr(t);
        t := t + 1;
     end;
   end;
     val(dd,d,error);
     if error <> 0 then
     begin
        delete(dd,1,error);
        val(dd,d,error);
     end;
     val(mm,m,error);
     if error <> 0 then
     begin
        delete(mm,1,error);
        val(mm,m,error);
     end;
     val(aa,a,error);
     if error <> 0 then
     begin
        delete(aa,1,error);
        val(aa,a,error);
        if error <> 0 then
        begin
        delete(aa,1,error);
        val(aa,a,error);
      end;
     end;
      d := word(d);
      m := word(m);
      a := word(a);
      diase := eldiaes(1,mes,ayo);
      diasem := diadesemana[eldiaes(dia,mes,ayo)];
  end;
 
  procedure cuadrocalendario(xx, yy : integer);
  begin
         gotoxy(xx,yy);write('ÚÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄ¿');
     gotoxy(xx,yy + 1);write('³ L ³ M ³ X ³ J ³ V ³ S ³ D ³');
     gotoxy(xx,yy + 2);write('ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄ´');
     gotoxy(xx,yy + 3);write('³   ³   ³   ³   ³   ³   ³   ³');
     gotoxy(xx,yy + 4);write('ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄ´');
     gotoxy(xx,yy + 5);write('³   ³   ³   ³   ³   ³   ³   ³');
     gotoxy(xx,yy + 6);write('ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄ´');
     gotoxy(xx,yy + 7);write('³   ³   ³   ³   ³   ³   ³   ³');
     gotoxy(xx,yy + 8);write('ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄ´');
     gotoxy(xx,yy + 9);write('³   ³   ³   ³   ³   ³   ³   ³');
    gotoxy(xx,yy + 10);write('ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄ´');
    gotoxy(xx,yy + 11);write('³   ³   ³   ³   ³   ³   ³   ³');
    gotoxy(xx,yy + 12);write('ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄ´');
    gotoxy(xx,yy + 13);write('³   ³   ³   ³   ³   ³   ³   ³');
    gotoxy(xx,yy + 14);write('ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄ´');
    gotoxy(xx,yy + 15);write('³   ³   ³   ³   ³   ³   ³   ³');
    gotoxy(xx,yy + 16);write('ÀÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÙ');
  end;
 
  procedure presentames(ms, an : word);
  var
    xx, l, y, x : integer;
    tt, i, pos : integer;
  begin
     x := 1;
     xx := 50;
     y := 7;
     i := 1;
     textcolor(15);
     cuadrocalendario(x + (xx + 1),y - 3);
     gotoxy(x + (xx + 10),y - 4);write(elmes[ms]);
     if bisiesto(an) then
     begin
        pos := diase;
        x := (pos * 4);
        tt := pos + 1;
        if pos = 0 then
        textcolor(4)
      else
        textcolor(15);
        gotoxy(xx + x,y);write(i);
        x := x + 4;
        for i := 2 to mesesbi[ms] do
        begin
           if tt > 7 then
           begin
           x := 1;
           x := (x * 4);
           pos := 0;
           y := y + 2;
           tt := 1;
           end;
           if tt = 7 then
           textcolor(12)
         else
           textcolor(15);
           gotoxy(xx + x,y);write(i);
           x := x + 4;
           tt := tt + 1;
        end;
     end
  else
     begin
        pos := diase;
        x := (pos * 5);
        tt := pos + 1;
        if pos = 0 then
        textcolor(4)
      else
        textcolor(15);
        gotoxy(xx + x,y);write(i);
        x := x + 5;
        for i := 2 to meses[ms] do
        begin
           if tt > 7 then
           begin
           x := 1;
           x := (x * 5);
           pos := 0;
           y := y + 2;
           tt := 1;
           end;
           if tt = 7 then
           textcolor(4)
         else
           textcolor(15);
           gotoxy(xx + x,y);write(i);
           x := x + 5;
           tt := tt + 1;
         end;
        end;
    end;
 
    procedure guardacalendariomes(ay : word; me, di : integer);
    begin
       assign(f,nombre);
  {$I-} reset(f); {$I+}
    if ioresult <> 0 then
    begin
        rewrite(f);
        dato.mestom := elmes[me];
        dato.ayotom := ay;
        dato.diatom[di] := chr(2);
        seek(f,0);
        write(f,dato);
        close(f);
    end
  else
    begin
        dato.mestom := elmes[me];
        dato.ayotom := ay;
        dato.diatom[di] := chr(2);
        seek(f,filesize(f));
        write(f,dato);
        close(f);
    end;
  end;
 
  procedure presentacalendariomes(ay : word; me, di : integer);
  var
    w : longint;
    si : boolean;
  begin
      si := false;
      assign(f,nombre);
  {$I-} reset(f); {$I+}
    if ioresult <> 0 then
    begin
       writeln('    Error De Archivo O No Existe Pulse Una Tecla');
       readkey;
    end
  else
     begin
        for w := 0 to filesize(f) - 1 do
        begin
          seek(f,w);
          read(f,dato);
          if (dato.mestom = elmes[me]) and (dato.ayotom = ay) then
          begin
            si := true;
            break;
          end;
        end;
        clrscr;
         if si = true then
         begin
         presentames(me,ay);
         readkey;
         end
    else
       begin
          writeln('    Datos No Encontrados Pulse una tecla');
          readkey;
       end;
     end;
  end;
 
 
  begin
     clrscr;
     tomafecha(dia,mes,ayo);
     presentames(mes,ayo);
     guardacalendariomes(ayo,mes,6);
     presentacalendariomes(ayo,mes,6);
     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
sin imagen de perfil

calendariooo AYUDAA!!

Publicado por Julieta (9 intervenciones) el 17/10/2016 22:48:27
lo cabo de ejecutar y entra en loop, osea empieza a crear la matriz una y otra vez sin parar, si lo pudieras arreglar seria genial!!
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

calendariooo AYUDAA!!

Publicado por ramon (2158 intervenciones) el 18/10/2016 23:05:15
solo esta para generar el calendario y los cuadros no ara mas tu tienes que realizar el resto si necesitas mas dímelo.
suerte.
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