Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program pregunta1;
- Const MaxLine=120;
- Procedure makeLn(var archOut:Text;ch:Char);
- var x:Integer;
- begin
- for x:=1 to MaxLine do write(archOut,ch);
- writeln(archOut);
- end;
- Procedure formato2(var archOut:Text; dato1,dato2,dato3:Integer; ch:Char);
- begin
- If dato1 <10 then write(archout,'0',dato1,ch) else
- if dato1=0 then write(archout,'00',ch) else
- write(archout,dato1,ch);
- If dato2 <10 then write(archout,'0',dato2,ch) else
- if dato2=0 then write(archout,'00',ch) else
- write(archout,dato2,ch);
- If dato3 <10 then write(archout,'0',dato3) else
- if dato3=0 then write(archout,'00') else
- write(archout,dato3);
- end;
- var nombArchIn,estac,ciudad,depar:String;
- archIn, archOut:Text;
- dd,mm,aa,regTotal,regF,diasTotal,fecha,h1,m1,s1,h2,m2,s2,tiempo,
- tiempoF,fini,ffinal:Integer;
- montoTotal,monto,montoF:Real;
- hayfechas:Boolean;
- begin
- //Procesar archivos
- write('Ingrese nombre del archivo: ');
- readln(nombarchin);
- assign(archIn, nombarchin);
- reset(archIn);
- assign(archOut, 'Reporte.txt');
- rewrite(archOut);
- //Crear Encabezado
- makeLn(archOut,'=');
- writeln(archout, 'INFORME DE PRECIPITACIONES':55);
- //Procesar por cede
- while not eof(archIn) do begin
- //Leer cede
- readln(archin, estac);
- readln(archin, ciudad);
- readln(archin, depar);
- //Imprimir cede
- writeln(archOut, 'ESTACION', 'CIUDAD':40, 'DEPARTAMENTO':40);
- writeln(archOut, estac, ciudad:40, depar:40);
- makeLn(archOut,'=');
- writeln(archOut, 'Fecha', 'Cantidad':20, 'Tiempo total':20,
- 'Total llovido':20, 'Promedio':20);
- //Procesar fechas
- hayfechas:=false;
- regTotal:=0;
- diasTotal:=0;
- montoTotal:=0;
- repeat
- readln(archin,dd, mm,aa);
- fecha:= aa*10000+mm*100+dd;
- //Verificar
- if dd<>0 then begin
- //Procesar datos
- regF:=0;
- tiempoF:=0;
- montoF:=0;
- while not eoln(archin) do begin
- read(archin, h1,m1,s1,h2,m2,s2,monto);
- inc(regF);
- tiempo:= (h2*3600+m2*60+s2)-(h1*3600+m1*60+s1);
- inc(tiempoF,tiempo);
- montoF:= montoF + monto;
- end;
- readln(archin);
- //Imprimir Datos
- formato2(archout,dd,mm,aa,'/');
- write(archout,regF:15);
- h1:=tiempoF div 3600;
- m1:=(tiempoF mod 3600)div 60;
- s1:=tiempoF mod 60;
- write(archout,' ':10);
- formato2(archout,h1,m1,s1,':');
- writeln(archout, montoF:15:2,' mm', montoF/(tiempoF div 60):15:2,
- ' mm/min');
- if not hayfechas then begin
- fini:=fecha;
- ffinal:=fecha;
- hayfechas:=not(hayfechas);
- end
- else begin
- if fecha < fini then fini:=fecha;
- if fecha > ffinal then ffinal:=fecha;
- end;
- //Guardar Info
- inc(regTotal, regF);
- inc(diasTotal);
- montoTotal:= montoTotal + montoF;
- end;
- until dd=0;
- //Imprimir Resumen
- makeLn(archOut, '-');
- writeln(archout,'Resumen:');
- write(archout,'Fecha inicial: ');
- formato2(archout, fini mod 100, fini mod 10000 div 100, fini div 10000, '/');
- write(archout,'Fecha final: ':15);
- formato2(archout, ffinal mod 100, ffinal mod 10000 div 100, ffinal div 10000, '/');
- writeln(archout);
- writeln(archout,'Cantidad total de registros: ',regTotal,
- 'Cantidad de dias registrados: ':35 ,diasTotal,
- 'Total llovido en el periodo: ':35,montoTotal:0:2);
- makeLn(archOut,'=');
- end;
- //Cerrar Archivo
- close(archOut);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement