Programación General > Pascal
Programa
lau82:
ESTA BIEN HECHO ASI? CUALES SON LOS ERRORES?
NOSE COMO PONER EL PORCENTAJE NI CUANDO DICE LLUVIA 1: SI O LLUVIA 2: NO
Program lluvias;
LLUVIAS (c:\DATOS.TXT)
Uses
Crt;
Var
dia,mes,año : = integer;
TempMax,TempMin: = real;
Sinllu,men50, mas50: =integer;
Precipitaciones : = real;
Porcentaje : = real;
Acumdias: = integer;
totallu: = real;
PromTemp := real;
Lluvia: = string;
Datos: = text;
Begin
Write(‘Ingrese el nombre del archivo: ‘);
Readln( lluvias);
ASSIGN(DATOS,LLUVIA); {Asignación a la variable DATOS del archivo en disco “lluvias”}
{Lo llamare precipitaciones.pas}
RESET(DATOS); {Apertura del archivo para leer datos desde el}
{Inicializacion de variables}
sinllu. = 0
men50: = 0
mas50: = 0
totallu:=0
ClrScr;
Repeat
Begin
If (precipitaciones =0 ) then sinllu: = sinllu + 1
Porcentaje:= acumdias * cantdias / 100
Else Write (¨No contar los dias¨);
Begin
If (precipitaciones > 0) and (precipitaciones < 50) then men50: = men50 + 1
Else Write (´No contar los dias’);
Begin
If (precipitaciones >=50) then mas50:= mas50 + 1
Else Write (´No contar los dias¨);
End;
End;
End;
Until precipitaciones < = 0
CLOSE (DATOS);
totllu: = totllu + 1
Prom: = (Tempmax + TempMin ) / 2
APPEND (DATOS) ;
WRITELN(DATOS) ;
WRITELN(DATOS, PROM) ;
WRITELN(DATOS,TOTLLU) ;
CLOSE(DATOS) ;
writeln('CANTIDAD DE DIAS SIN LLUVIA: ',SINLLU);
writeln('CANTIDAD DE DIAS QUE LLOVIO MENOS DE
50mm: ',men50);
writeln('CANTIDAD DE DIAS QUE LLOVIA IGUAL O MAS DE 50
mm ',MAS50);
writeln('PRECIPITACIONES ACUMULADAS ',TOTALLU);
writeln('EL PORCENTAJE DE DIAS SIN LLUVIAS
ES ',);
writeln('PROMEDIO DE TEMPERATURAS');
readln,
End.
Enko:
--- Citar ---ESTA BIEN HECHO ASI? CUALES SON LOS ERRORES?
--- Fin de la cita ---
Si compila, y hace lo que tiene que hacer, entonces no veo cual es el problema.
Igualmente, te planteo como podrías hacerlo comodo:
*)realiza un menú cuando comienza la ejecucion de este tipo:
--- Citar ---1) Ingresar Datos
2)Ver dias con lluvia
3)Ver temperatura promedia
4)Ver mm precipitados promedio
5),.....etc....
6)Salir
--- Fin de la cita ---
*) en la opcion 1, lo unico que tiens que hacer es pedir todos los datos con alguna verificacion y guardarlos en un archivo de texto.
*) con el resto de las opciones, simplemente vas leyendo del archivo todos los datos y sacas el promedio que corresponde.
--- Citar ---TotalDias: Integer;
DiasLluvia: Integer;
Lluvia: Byte; // 1 o 2
........ leiste todos los datos
TotalDias := TotalDias + 1;
if Lluvia = 1 then DiasLLuvia := DiasLluvia+1;
.... otras cosas
DiasNoLluvia := TotalDias - DiasLluvia;
--- Fin de la cita ---
Para la lluvia:
lau82:
sin usar byte, se puede poner
WRITE (‘SI LLOVIO INGRESO 1 SINO 2’)
READ('LLUVIA')
IF LLUVIA:= 2 THEN CL:= CL + 1
ELSE ( ACA NOSE QUE PONER?)
Enko:
--- Cita de: "lau82" --- sin usar byte, se puede poner
WRITE (‘SI LLOVIO INGRESO 1 SINO 2’)
READ('LLUVIA')
IF LLUVIA:= 2 THEN CL:= CL + 1
ELSE ( ACA NOSE QUE PONER?)
--- Fin de la cita ---
y para que quieres ponerle algo si realmente no tienes que poner nada?!!!!!!
--- Código: Text --- WRITE (‘SI LLOVIO INGRESO 1 SINO 2’)READ('LLUVIA')IF LLUVIA:= 2 THEN CL:= CL + 1; en un IF no tienes proque poner un ELSE
Saiyan1:
--- Citar ---y para que quieres ponerle algo si realmente no tienes que poner nada?!!!!!!
--- Fin de la cita ---
Jejeje...
me mataste con esa Enko.... xD :kicking:
Navegación
[#] Página Siguiente
[*] Página Anterior
Ir a la versión completa