Advertisement
kalin729

Seconds to yrs,days,hrs,mins,secs

Oct 22nd, 2016
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. //31556926 - Гугъл
  4. //31536000 - Петър
  5. int main ()
  6. {
  7.  long long int tot_sec, sec, min, hr, days,yrs;
  8.  cout << "Enter seconds: ";
  9.  cin >> tot_sec;
  10.  yrs = tot_sec / 31536000;
  11.  
  12.  days = (tot_sec - (yrs*31536000)) / 84600;
  13.  hr = (tot_sec - (yrs*31536000) - (days*84600)) / 3600;
  14.  min = (tot_sec - (yrs*31536000) - (days*84600) - (hr*3600)) / 60;
  15.  sec = (tot_sec - (yrs*31536000) - (days*84600) - (hr*3600) - (min*60));
  16.  cout<<yrs<<"yrs," << days <<"days," << hr << "hrs," << min << "mins," << sec << "seconds" << endl;
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement