Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int liczbaSekund, pozostaleSekundy;
- int liczbaDni, liczbaGodzin, liczbaMinut;
- cout << "Podaj liczbe sekund: ";
- cin >> liczbaSekund; //przykład: 31600000
- liczbaDni = liczbaSekund/86400; //86400 - ilość sekund w dobie
- pozostaleSekundy = liczbaSekund%86400;
- liczbaGodzin = pozostaleSekundy/3600; //3600 - ilość sekund w godzinie
- pozostaleSekundy %= 33600;
- liczbaMinut = pozostaleSekundy/60; //60 - ilość sekund w minucie
- pozostaleSekundy %= 60;
- cout << liczbaSekund << " sekund = " << liczbaDni << " dni, ";
- cout << liczbaGodzin << " godzin, " << liczbaMinut << " minut, " << pozostaleSekundy << " sekund" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement