• Lenguaje

    Pascal

  • Descripción

    La distancia entre Trujillo y Chiclayo es de 200 km. Si un conductor parte el día lunes de Trujillo a una velocidad constante de X km/h, y el día martes repite el mismo procedimiento a Y km/h. ¿Que día llega más rápido a Chiclayo y que tiempo se demora?.

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
program DistanciaEntreTrujilloYChiclayo;
uses crt;

var X, Y, tiempo_en_horas_lunes, tiempo_en_horas_martes, tiempo_mas_rapido : real;
begin
    write ('Ingresa el valor de X: ');
    readln (X);
    write ('Ingresa el valor de Y: ');
    readln (Y);
    tiempo_en_horas_lunes := 200/X;
    tiempo_en_horas_martes := 200/Y;
    if tiempo_en_horas_lunes<tiempo_en_horas_martes then
        begin
            tiempo_mas_rapido := tiempo_en_horas_lunes;
            writeln ('Llega m'#160's r'#160'pido el Lunes.');
        end
    else
        begin
            tiempo_mas_rapido := tiempo_en_horas_martes;
            writeln ('Llega m'#160's r'#160'pido el Martes.');
        end;
    writeln ('Valor de tiempo en horas lunes: ', tiempo_en_horas_lunes:0:6);
    writeln ('Valor de tiempo en horas martes: ', tiempo_en_horas_martes:0:6);
    writeln ('Valor de tiempo mas rapido: ', tiempo_mas_rapido:0:6);
    writeln;
    write ('Presiona una tecla para terminar . . . ');
    readkey;
end.