Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int main(){
- int odleglosc, godziny1 ,minuty1 ,godziny2 ,minuty2;
- int czas1, czas2, czas;
- printf("Podaj odlegosc\n");
- scanf("%d", &odleglosc);
- printf("Podaj godzine odjazdu\n");
- scanf("%d:%d", &godziny1, &minuty1);
- if(minuty1 >= 60){
- minuty1 = minuty1%60; godziny1++;
- }
- if(godziny1 >= 24){
- godziny1 = godziny1%24;
- }
- printf("Podaj godzine przyjazdu\n");
- scanf("%d:%d", &godziny2, &minuty2);
- if(minuty2>=60){
- minuty2=minuty2%60; godziny2++;
- }
- if(godziny2 >= 24){
- godziny2 = godziny2%24;
- }
- czas1 = godziny1 + (float)minuty1/60;
- czas2 = godziny2 + (float)minuty2/60;
- if(czas2 <= czas1) {
- czas = 24 - czas1 + czas2;
- } else {
- czas = czas2 - czas1;
- }
- float szybkosc = (float)odleglosc/(float)czas;
- printf("Potrzebna predkosc to %d km/h\n", (int)szybkosc);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement