Advertisement
Nakumas

JPO: ćwiczenia 1, zadanie 5

Feb 21st, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int liczbaSekund, pozostaleSekundy;
  7.     int liczbaDni, liczbaGodzin, liczbaMinut;
  8.  
  9.     cout << "Podaj liczbe sekund: ";
  10.     cin >> liczbaSekund; //przykład: 31600000
  11.  
  12.     liczbaDni = liczbaSekund/86400; //86400 - ilość sekund w dobie
  13.     pozostaleSekundy = liczbaSekund%86400;
  14.  
  15.     liczbaGodzin = pozostaleSekundy/3600; //3600 - ilość sekund w godzinie
  16.     pozostaleSekundy %= 33600;
  17.  
  18.     liczbaMinut = pozostaleSekundy/60; //60 - ilość sekund w minucie
  19.     pozostaleSekundy %= 60;
  20.  
  21.     cout << liczbaSekund << " sekund = " << liczbaDni << " dni, ";
  22.     cout << liczbaGodzin << " godzin, " << liczbaMinut << " minut, " << pozostaleSekundy << " sekund" << endl;
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement