Calculate the Timetable in C. Financial year

Asked

Viewed 149 times

-4

I started programming recently and I’m having trouble solving this exercise:

Write a program that reads the departure time (hours and minutes) of a flight, the travel time and the difference in hours of the destination time zone. The programme must indicate the local time at the scheduled destination for the arrival of the flight. Please note that the flight may arrive the following day.

I’m having trouble with the date and time scanf part and also the time zone.

  • And how you will represent the hours, minutes and time zone (or it will be the time difference)?

  • 1

    https://pt.meta.stackoverflow.com/a/5486/112052

  • Any shape can be . the zone of summing or subtracting.

  • hkotsubo, I’m asking for help not to do for me, I’m in this exercise for 2 days unable to solve and I saw many tutorials and researched. If you don’t want to teach, hug and have a good day..

  • 1

    Important you [Dit] your question and explain objectively and punctually the difficulty found, accompanied by a [mcve] of the problem and attempt to solve. What Mr @hkotsubo commented about, is the helpful help right now, there’s this other one here too: Stack Overflow Survival Guide in English. If you don’t want to learn the requirements for questions asked on the site, well... hug and have a good day. If you want, on the other hand, to have a lot of legal material at your disposal, just pay attention to the guidance of your more experienced colleagues.

  • @Bacco you confused the intentions of hkotsubo open the link and vera that is directed to the post "Think that we will do all your work for free", there is no attempt to help. I started programming now and do not know the rules of the site or the culture of programmers, I will read the links you sent me to inform me more. Thank you.

  • 2

    @Eduardofabricio the link is an official document of the community, and has much more information than the one that bothered you (if suggested, it is up to you to make the post does not fit the problems listed). If you read with the intention of learning you will have something useful there (and the other link I passed). These guidelines are for you to understand what works and what doesn’t work here, and especially how to meet the objectives of the site (if you understand, everyone wins, if you don’t understand ends up leaving dissatisfied and still leaves posts that disturb the community). It’s not a dispute.

  • 2

    When you just put the statement and do not put the code that already tried, nor objectively explain the problem ("I’m having trouble to do X" is a very vague description), the impression that passes It’s just that you want them to do everything for you, hence the link I informed you about. If you read the other links you will also understand that the idea of the site is not to provide individual Helpdesk. And just for the record, the answer below may result in negative hours depending on the time zone, so it should not even be accepted, it ends up causing the quality of the site - which is no longer good - to fall further into disrepute...

Show 3 more comments

1 answer

0


Using whole fields set and read time of departure (0 to 23), minute of departure (0 to 59), hours of flight duration (0 to 24), minutes of flight duration (0 to 59), difference in hours of the destination time zone (-12 to +12).
Calculate:

minuto de chegada = minuto da partida + minutos de duração do voo
se (minutos de chegada > 60) então
    hora extra = 1
    minuto de chegada = minuto de chegada - 60
senao
    hora extra = 0
    fimse
hora de chegada = hora da partida + horas de duração do voo + hora extra - fuso horário do destino
se (hora de chegada > 24) então
    dia = 1
    hora de chegada = hora de chegada - 24
senao
    dia = 0
fimse
imprima dia, hora e minuto de chegada

Another possibility is to use the data types and functions of <time.h>.

  • I managed to solve it by doing some crazy tricks that I don’t even know why it’s working, but thanks.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.